I'm working on a site that is forced to use a media conversion server. That server lets me issue the imagemagick parameters, but not the actual convert command, so multiple commands are out.
I have an image that I need resized, then I need that resized image cropped twice. I need all three resulting images saved separately.
Doing multiple calls to the conversion server will mean I basically have to develop a communication system between all the requests, so that I know when to do the next step, since the server uses callback urls and I don't have control over the info it sends back.
I've been playing around with something like this,
convert ./image.png -resize 160x320 -write ./image-resize.png -crop 50x50+15+15 -write ./image-cropped-1.png -crop 25x25+10+10 ./image-cropped-2.png
But the second crop will crop the result of the first crop. Is there way to do two different crops on the resized image in the same command?
Thanks,
Brandon
Switching input file mid command
Re: Switching input file mid command
This is probably what you are looking for there are other methods that you can use - some php examples on my site:
http://www.rubblewebs.co.uk/imagemagick ... o_temp.php
http://www.rubblewebs.co.uk/imagemagick ... o_temp.php
Code: Select all
input.png -resize 160x320 -write mpr:image +delete \( mpr:image -crop 50x50+15+15 -write image-cropped-1.png \) \( mpr:image -crop 25x25+10+10 -write image-cropped-2.png \)
Re: Switching input file mid command
What is that mpr:image
Re: Switching input file mid command
I ended up doing this, because I need to base the crops off the result from the resize. Seems to work,
Code: Select all
convert ./image.png -resize 160x320 -write ./image-resize.png -crop 100x100+15+15 -write ./image-cropped-1.png +delete ./image-resize.png -crop 50x50+10+10 ./image-cropped-2.png
Re: Switching input file mid command
The mpr: is writing the image to memory.
So the comand I posted resizes the original image and saves it to memory; it then takes the image in memory and crops it - saves the crop then recalls the image from memory and crops that and saves it.
As I said there are different methods to acheve the same result; you have one tempory image that needs clearing up and I do not - unless you wanted the original resized image as well.
So the comand I posted resizes the original image and saves it to memory; it then takes the image in memory and crops it - saves the crop then recalls the image from memory and crops that and saves it.
As I said there are different methods to acheve the same result; you have one tempory image that needs clearing up and I do not - unless you wanted the original resized image as well.
Re: Switching input file mid command
That makes sense. I do need the original resized image, so I guess I have to go that route. But that memory command could definitely come in handy down the road. Thanks a lot. Saved me quite a bit of misery.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Switching input file mid command
see clone and parenthesis processing
convert \( someimage command -write someoutput \) \
\( previous-someoutput command -write new-someoutput \)
etc
http://www.imagemagick.org/Usage/basics/#image_seq
convert \( someimage command -write someoutput \) \
\( previous-someoutput command -write new-someoutput \)
etc
http://www.imagemagick.org/Usage/basics/#image_seq