By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,905 Members | 1,732 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,905 IT Pros & Developers. It's quick & easy.

Use to use mogrify to create a thumbnail of an image

P: n/a
[PHP]
$mogResponse = exec("mogrify -size ${width}x$height " .
$this->locationPath . '/' . $this->fileName . '
-resize ' .
$width . "x$height > +profile " .
$this->thumbLocationPath . '/' . $this->fileName
.. ' 2>&1');
[/PHP]

This attempt at creating a thumbnail only causes the original image to
be resized while creating a "ghost image" in the /thumb folder where
the thumbnail should be.

Could someone show me exactly how to use mogrify to generate a
thumbnail in another folder while keeping the original image intact?

BTW imagecreatetruecolor() is not an option in this case because I'm
working with PHP 4.1.2

Thanks
Phil
Jul 17 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Tue, 27 Jul 2004 15:35:38 -0700, Phil Powell wrote:
[PHP]
$mogResponse = exec("mogrify -size ${width}x$height " .
$this->locationPath . '/' . $this->fileName . '
-resize ' .
$width . "x$height > +profile " .
$this->thumbLocationPath . '/' . $this->fileName
. ' 2>&1');
[/PHP]

This attempt at creating a thumbnail only causes the original image to
be resized while creating a "ghost image" in the /thumb folder where
the thumbnail should be.

Could someone show me exactly how to use mogrify to generate a
thumbnail in another folder while keeping the original image intact?

The answer is to make a copy Phil, then work on that one =)

BTW imagecreatetruecolor() is not an option in this case because I'm
working with PHP 4.1.2

Maybe not the best code in the world but it does work and maybe useful to
you:
<http://tk.digiserv.net/dLib_IMagick_Simple.class.phps>
It does little more than what you're asking.. an example:
<?php
require_once('dLib_IMagick_Simple.class.php');

$image_filename = 'foo.png';
$image_width = 300; /* Resized width */
$image_height = 240; /* Resized height */
$display_image = false; /* Self explanitory option */
$scaling = true; /* Force size or scale image */
$overwrite_image = false; /* Return false or overwrite image */

$img = new IMagick_Simple;
$img->debug(true) /* Optional verbose debugging */

/* Note the following 2 can be the same location */
$img->thumbs_path('/full/path/to/dir/for/destination/image/');
$img->fullsize_path('/full/path/to/dir/with/original/image/');

if (!$img->thumb(
$image_filename,
$image_width,
$image_height,
$display_image,
$scaling,
$overwrite_image
)) {
die($img->error_msg()); /* Pointless if debug == true */
}
?>
If all goes well, you should have 'foo.png' as your original image and
't_foo.png' as the resized ( / scaled) image.

Some vars above are used unneccessarily.. but there's no docs per-se for
the class.. so hopefully this outlines the usage a little better (although
the debug error msgs do contain the syntax).

If any use.. feel free to do as you wish with the code (re-use / modify
/ use chunks of).. but would be nice to leave the header intact =)

HTH anyway.

Regards,

Ian

--
Ian.H
digiServ Network
London, UK
http://digiserv.net/

Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.