Snippets - With php

Snippets index page

NOTE: Most of the IM snippets have been tested on IM version 6.3.5 There may be some differences if you are using the code on other versions.

New image size in variable - Anthony 26/6/2008

This will resize an image and put the new image details into a vairable. You can either use the variable elsewhere in your code or display it. In this case it is reading the width and height; you should be able to use any of the information for -format.

  1. <?php
  2. // Setup the vaiables
  3. $sourceFile "input.jpg";
  4. $width "100";
  5. $height "100";
  6. $destinationFile "output.png";
  7. // Displays the output size of the new image
  8. $command="convert $sourceFile -resize {$width}x{$height} \( +write $destinationFile \) -format \"%wx%h\" info: ";
  9. $output exec("$command"); 
  10. print("<b>New image size:</b>".$output."<br>");
  11. ?>

For more examples and information check out the main Imagemagick section.

Batch file View

Check size before resizing View

Dividing an image View

Fonts Installed view View

Get image data into a variable 1 View

Get image data into a variable 2 View

Gravity option View

New image size in variable View

Row of images View

Setup Information View

Use an array View

Warhol effect View