Log in

View Full Version : ImageMagick - image rotate - no work



lse123
01-04-2012, 06:05 AM
ImageMagick-I use XAMPP LOCAL HOST(not yet installed), Also in my godaddy hosting shared Linux ultimate(installed)

http://www.polisphotos.com/jQueryPb/7-3-rotation/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


$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/

james438
01-04-2012, 08:01 AM
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:


<?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.


<?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/command-line-options.php
More on ImageMagick syntax here: http://www.imagemagick.org/Usage/api/

lse123
01-04-2012, 08:52 AM
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!

james438
01-04-2012, 09:08 AM
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.

lse123
01-04-2012, 11:10 AM
what about my code - eg. in a web app not a system command...? urls of images must be absolute urls?

james438
01-04-2012, 10:59 PM
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
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.

lse123
01-04-2012, 11:44 PM
I mean not use "system" but something like: // urls of images must be absolute urls?

$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;

}

?>

james438
01-05-2012, 05:13 AM
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.


<?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?

lse123
02-23-2012, 08:29 PM
Version: ImageMagick 5.5.6 04/01/03 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 2003 ImageMagick Studio LLC

have given the:

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

lse123
02-23-2012, 08:34 PM
what if i have a web form and control/try use, imagick from it... them must use again system commands?

lse123
02-28-2012, 04:53 PM
asap answer required

james438
02-28-2012, 05:32 PM
It could be that no one here knows the answer or maybe they do not know exactly what it is you are trying to do.

To answer your question: as far as I can tell you still must use the system commands. I do not see a way around this.

Another place to seek answers is the ImageMagick forums itself. Go here (http://www.imagemagick.org/discourse-server/index.php) and post your question in the "Users" forum.

lse123
02-28-2012, 08:52 PM
http://www.phpro.org/tutorials/Imagick.html

have a look here

lse123
03-07-2012, 06:31 PM
my hosting provider says:
ImageMagick is a powerful set of image manipulation utilities that you can access through your code to create, edit, and compose bitmap images. There are many Web applications that use ImageMagick to manipulate images, or, if you're an experienced programmer, you can use Perl or PHP to access ImageMagick's convert utility.

The convert path to ImageMagick, version 5 on our servers is:

/usr/bin/

The convert path to ImageMagick, version 6 on our servers is:

/usr/local/bin/

well, what is:
"The convert path to ImageMagick"?
images read from / images saved to, or...?

james438
03-07-2012, 08:23 PM
I am not sure what you would need the convert path to ImageMagick for or how you would use it.

Images are read from the relative root directory. For example if your image is in your images folder under the file name gdsample.jpg then you can manipulate it with a simple script like:


<?php
header('Content-Type: image/jpg');
system("convert images/pops/gdsample1.jpg -flop jpg:-");
?>

<?php and ?> says read everything inbetween as php code.
header('Content-Type: image/jpg'); says display the content (or output) to the person viewing the page as an image and in particular a jpg image.

system("convert images/gdsample1.jpg -flop jpg:-");
The above code is the ImageMagick code. As you can see the path to ImageMagick is not being referenced except for using the command system.

lse123
03-08-2012, 12:49 PM
http://www.polisphotos.com/jQueryPb/images/ui-icons_ef8c08_256x240.png


<?php
header('Content-Type: image/png');
system("convert http://www.polisphotos.com/jQueryPb/images/ui-icons_ef8c08_256x240.png -flop png:-");
?>


this worked right as you see at http://www.polisphotos.com/jQueryPb/7-imagick/imagick3.php

well what if I want to use $im = new Imagick($image); // to built web forms that modify images // not use system... is it new Imagick($image); supported by 5.5.6 version?

james438
03-08-2012, 09:08 PM
Have you asked in the ImageMagick forums like I mentioned earlier?