Hi, I want to break a complex Imagemagic command into small simpler steps. Can someone please help me. We can create some intermediate temp files for intermediate steps. The command is :
convert subject.jpg -colorspace gray ( +clone -blur 0x2 ) +swap -compose divide -composite -linear-stretch 5%x0% -level 0%,100%,0.25 a.png
Here subject.jpg is the source image. I want to break it something like :
convert subject.jpg - colorspace gray a1.png
convert a1.png +clone -blur 0X2 a2.png
etc etc
Thanks in advance!
Break complex command into simpler steps...
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Break complex command into simpler steps...
Code: Select all
convert subject.jpg -colorspace gray a1.png
convert a1.png -blur 0X2 a2.png
convert a1.png a2.png +swap -compose divide -composite a3.png
convert a3.png -linear-stretch 5%x0% a4.png
convert a4.png -level 0%,100%,0.25 a.png
Code: Select all
convert subject.jpg -colorspace gray -write a1.p ( +clone -blur 0x2 -write a2.png ) +swap -compose divide -composite -write a3.png -linear-stretch 5%x0% -write a4.png -level 0%,100%,0.25 a.png
Re: Break complex command into simpler steps...
Thanks a lot for your response.
Actually I want to convert this command to php code using IMagick. I am still not sure how to create the php script for the third command here :
convert a1.png a2.png +swap -compose divide -composite a3.png
What is it actually doing. Is it possible to further break it and then composite the images to create a3.png?
Thanks,
Amit
Actually I want to convert this command to php code using IMagick. I am still not sure how to create the php script for the third command here :
convert a1.png a2.png +swap -compose divide -composite a3.png
What is it actually doing. Is it possible to further break it and then composite the images to create a3.png?
Thanks,
Amit
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Break complex command into simpler steps...
It is the same as
or
which cannot be reduce further. See
http://us3.php.net/manual/en/imagick.compositeimage.php
But http://us3.php.net/manual/en/imagick.co ... ompositeop does not list a divide composite option. Perhaps this document is old and there is a newer documents with divide as an option.
Imagick has not been maintained to keep up with Imagemagick. I would suggest you use PHP exec() for the whole command or at least for this one part.
Code: Select all
convert a2.png a1.png -compose divide -composite a3.png
Code: Select all
composite -compose divide a1.png a2.png a3.png
http://us3.php.net/manual/en/imagick.compositeimage.php
But http://us3.php.net/manual/en/imagick.co ... ompositeop does not list a divide composite option. Perhaps this document is old and there is a newer documents with divide as an option.
Imagick has not been maintained to keep up with Imagemagick. I would suggest you use PHP exec() for the whole command or at least for this one part.
Re: Break complex command into simpler steps...
Thanks. Now I understood the command, but you are right that the "Divide" blend type is not mentioned in IMagic documentation
Using exec command is definitely an option but that involves saving the image file we receive from UI to a server location, use exec to run the commands in which more temp files are created and finally output image created on server to be picked and shared back with UI for display. We thought having so many I/O operations will decrease the performance and also we have to take care of concurrent users situation.
Using exec command is definitely an option but that involves saving the image file we receive from UI to a server location, use exec to run the commands in which more temp files are created and finally output image created on server to be picked and shared back with UI for display. We thought having so many I/O operations will decrease the performance and also we have to take care of concurrent users situation.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Break complex command into simpler steps...
You can run this whole command line in one PHP exec() command
Code: Select all
convert subject.jpg -colorspace gray ( +clone -blur 0x2 ) +swap -compose divide -composite -linear-stretch 5%x0% -level 0%,100%,0.25 a.png
Re: Break complex command into simpler steps...
fmw42's example takes the image modifies it and saves it without any temporary files.
As far as I know Imagick needs the image saving on the server to start with as well.
If on a Linux type server you will need to change ( +clone -blur 0x2 ) to \( +clone -blur 0x2 \)
Imagick is limited in its options and seems to get updated in steps as another developer takes it over.
As far as I know Imagick needs the image saving on the server to start with as well.
If on a Linux type server you will need to change ( +clone -blur 0x2 ) to \( +clone -blur 0x2 \)
Imagick is limited in its options and seems to get updated in steps as another developer takes it over.