How can i generate multiple images in a single command

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
satya

How can i generate multiple images in a single command

Post by satya » 2010-01-27T00:10:14-07:00

Hi,
How can i generate multiple(output)images in a single (input) images?

I'm creating multiple size thumbnails with image magic multiple calls. Below is code.

Code: Select all

 convert 7070248.jpeg -resize 323x242 -quality 100 1272.jpeg
 convert 7070248.jpeg -resize 40x28 -quality 100 1273.jpeg
 convert 7070248.jpeg -resize 445x335 -quality 100 1274.jpeg
I want create all(1272.jpeg,1273.jpeg,1274.jpeg) of image in a single command. May be my idea is not correct.

Code: Select all

 convert 7070248.jpeg -resize 323x242 -quality 100 1272.jpeg -resize 323x242 -quality 100 1273.jpeg -resize 323x242 -quality 100 1274.jpeg
or 
 convert 7070248.jpeg -resize 323x242  40x28 445x335 -quality 100 1272.jpeg 1273.jpeg 1274.jpeg
Is this possible to generate multiple images in a single input via image magic.

Please let me know your suggestion or though. this is very important for me.

Thanks in advance.:)

Bonzo
Posts: 2963
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How can i generate multiple images in a single command

Post by Bonzo » 2010-01-27T01:05:21-07:00

Try:

Code: Select all

convert 7070248.jpeg ( +clone -resize 323x242  -quality 100 -write 1272.jpg +delete ) ( +clone -resize 445x335 -quality 100 -write 1274.jpg +delete )  -resize 40x28 -quality 100 1273.jpg 

satya

Re: How can i generate multiple images in a single command

Post by satya » 2010-01-27T02:56:05-07:00

Thanks for quick response.

What happened if i remove "+delete" from command.

after my research this command increase performance. what is your thinking for using this command.

Thanks

Bonzo
Posts: 2963
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: How can i generate multiple images in a single command

Post by Bonzo » 2010-01-27T10:58:45-07:00

Some info on delete here: http://www.imagemagick.org/script/comma ... php#delete
I would check if you remove the +delete that you are actualy modifying the input image and not the last image created.
I do not know you are using the code but it may take up space in the memory or tempory folder. If you are not modifying very large images the memory and tempory images should be deleted automaticaly by the system ?

Here is a different method is it any quicker ?

Code: Select all

convert 7070248.jpeg -write mpr:image +delete ( mpr:image -resize 323x242  -quality 100 -write 1272.jpg ) ( mpr:image -resize 445x335 -quality 100 -write 1274.jpg ) ( mpr:image -resize 40x28 -quality 100 1273.jpg )

satya

Re: How can i generate multiple images in a single command

Post by satya » 2010-01-27T11:21:29-07:00

Thanks for nice replay. This would help me to implement right application.

tkp
Posts: 1
Joined: 2018-02-11T05:40:19-07:00
Authentication code: 1152

Re: How can i generate multiple images in a single command

Post by tkp » 2018-02-11T05:54:04-07:00

Bonzo wrote:
2010-01-27T10:58:45-07:00
Here is a different method is it any quicker ?
Tested both nesting method to crop a 10000 x 10000 image to 2048 x 2048 tiles.

- original bash for loop : 191s
- mpr:image method : 32s
- +clone method : 32s

So both method seem to be equivalent for this use case, and are huge time saver.

Thanks both for asking and answering this helpful question !

Post Reply