Use to use mogrify to create a thumbnail of an image

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Phil Powell

    #1

    Use to use mogrify to create a thumbnail of an image

    [PHP]
    $mogResponse = exec("mogrify -size ${width}x$heigh t " .
    $this->locationPath . '/' . $this->fileName . '
    -resize ' .
    $width . "x$height > +profile " .
    $this->thumbLocationP ath . '/' . $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 imagecreatetrue color() is not an option in this case because I'm
    working with PHP 4.1.2

    Thanks
    Phil
  • Ian.H

    #2
    Re: Use to use mogrify to create a thumbnail of an image

    On Tue, 27 Jul 2004 15:35:38 -0700, Phil Powell wrote:
    [color=blue]
    > [PHP]
    > $mogResponse = exec("mogrify -size ${width}x$heigh t " .
    > $this->locationPath . '/' . $this->fileName . '
    > -resize ' .
    > $width . "x$height > +profile " .
    > $this->thumbLocationP ath . '/' . $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?[/color]


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

    [color=blue]
    > BTW imagecreatetrue color() is not an option in this case because I'm
    > working with PHP 4.1.2[/color]


    Maybe not the best code in the world but it does work and maybe useful to
    you:


    <http://tk.digiserv.net/dLib_IMagick_Si mple.class.phps >


    It does little more than what you're asking.. an example:


    <?php
    require_once('d Lib_IMagick_Sim ple.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_imag e = 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_imag e
    )) {
    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


    Comment

    Working...