Page 1 of 2 12 LastLast
Results 1 to 10 of 17

Thread: ImageMagick - image rotate - no work

  1. #1
    Join Date
    Jan 2012
    Posts
    74
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default ImageMagick - image rotate - no work

    ImageMagick-I use XAMPP LOCAL HOST(not yet installed), Also in my godaddy hosting shared Linux ultimate(installed)

    http://www.polisphotos.com/jQueryPb/...ion/images.php

    Imagick statements like below must be supported in my Ultimate shared Linux plan? Rotate does not operate, copy from jQuery book…currently reading "jQuery 1.3 with PHP" by Packt Publ, in the 7th chapter refers for Imagick for use from PHP for image rotate among first topics, but seems no work

    Code:
    $manipulated=0;
    
       $effects=array('rotate');
    
       foreach($effects as $eff)if(isset($_REQUEST[$eff]))$manipulated=1;   
    
    if(!$manipulated)readfile($froot.$fname);
    
       else{
    
       	 $image=new Imagick($froot.$fname);
    
       	 if(isset($_REQUEST['rotate'])){
    
       		   $image->rotateImage(new ImagickPixel(),(int)$_REQUEST['rotate']);
    
       	 }
    
       	 echo $image;
    
       }
    
       ?>
    What is: "The convert path to ImageMagick."


    what its mean by "convert path"(for imageMagick), needed in code, where?
    Is it the folder images go or...? I just apply the code from the book...
    /usr/bin/

  2. #2
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Beats me what "The convert path to ImageMagick." means. Nor do I understand the code.

    I do have ImageMagick installed on my Deluxe GoDaddy hosting account. Try this:

    Code:
    <?php
    header('Content-Type: text/plain');
    system("convert -version");
    ?>
    The above code will tell you if you have ImageMagick or not and what version it is.

    The following will take an image named testimage.jpg and rotate it by -36 degrees and output it in jpg format.

    Code:
    <?php
    header('Content-Type:image');
    system("convert testimage.jpg -rotate -36< -write testimage.jpg jpg:-");
    ?>
    From what I can tell system calls the convert command so that convert can be used. convert calls the ImagMagick functions like -rotate. functions are prefaced with a dash. In this case we take testimage.jpg and use the function -rotate and rotate it by -36 degrees. If I wanted to rotate it by 36 degrees I would use +36<. The < is used because the image is originally wider than it is tall. If it were a tall image then I would use -36> instead.

    The rest I am less sure about. From what I can understand -write is the command to save the image under the name testimage.jpg and jpg:- is the format to output the image in to your browser.

    You can read more about the functions here: http://www.imagemagick.org/script/co...ne-options.php
    More on ImageMagick syntax here: http://www.imagemagick.org/Usage/api/
    To choose the lesser of two evils is still to choose evil. My personal site

  3. #3
    Join Date
    Jan 2012
    Posts
    74
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    may run imageMagick from a hosting domain(secondary domain in a sub-folder of root) other than main hosting domain?
    exist any predefined folders of imageMagick must be used?

    I mean in normal code not like "system" code...you provided,...

    I am going to try your commands now, thanks!

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Not that I know of. The code I showed you should run in any folder on your site. There is no path needed in your case.
    To choose the lesser of two evils is still to choose evil. My personal site

  5. #5
    Join Date
    Jan 2012
    Posts
    74
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    what about my code - eg. in a web app not a system command...? urls of images must be absolute urls?

  6. #6
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Do you mean like a browser or ipad app? In that case the path you are trying to use to call the ImageMagick functions will most likely vary. With the absolute paths of the images from other sites just try it and see. It works fine for me. I used:

    PHP Code:
    <?php
    header
    ('Content-Type:image');
    system("convert http://livehope.org/wp-content/uploads/2011/05/youth2.jpg -rotate -90< -write testimage.jpg jpg:-");
    ?>
    The other examples I gave were of relative addresses. The one above uses an absolute address.
    To choose the lesser of two evils is still to choose evil. My personal site

  7. #7
    Join Date
    Jan 2012
    Posts
    74
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    I mean not use "system" but something like: // urls of images must be absolute urls?
    Code:
    $manipulated=0;
    
       $effects=array('rotate');
    
       foreach($effects as $eff)if(isset($_REQUEST[$eff]))$manipulated=1;   
    
    if(!$manipulated)readfile($froot.$fname);
    
       else{
    
       	 $image=new Imagick($froot.$fname);
    
       	 if(isset($_REQUEST['rotate'])){
    
       		   $image->rotateImage(new ImagickPixel(),(int)$_REQUEST['rotate']);
    
       	 }
    
       	 echo $image;
    
       }
    
       ?>

  8. #8
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    In regards to the script you just posted I do not understand it. I can not help you with the script you just posted.

    I hope I can explain a little bit about ImageMagick and help you write a script that does what you want. I only know a little about ImageMagick though.

    Here is a slight variation of the script I have been posting. This one is in a folder one lower than the image file that we are trying to manipulate. It will get the file, modify it and then in the second line it will save the image in the same folder that the script is located. This uses relative urls as opposed to absolute urls in my previous example. I am also saving the file to a different folder in this example as opposed to my previous example.

    Code:
    <?php
    header('Content-Type:image');
    system("convert ../testimage.jpg -rotate -36< -write testimage.jpg jpg:-");
    system("convert ../testimage.jpg -rotate -36< -write testimage.jpg");
    ?>
    Does this help?
    Last edited by james438; 01-05-2012 at 10:33 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  9. #9
    Join Date
    Jan 2012
    Posts
    74
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    Version: ImageMagick 5.5.6 04/01/03 Q16 http://www.imagemagick.org
    Copyright: Copyright (C) 2003 ImageMagick Studio LLC

    have given the:
    Code:
    <?php
    header('Content-Type: text/plain');
    system("convert -version");
    ?>

  10. #10
    Join Date
    Jan 2012
    Posts
    74
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Default

    what if i have a web form and control/try use, imagick from it... them must use again system commands?

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •