Batch composite with resize

ImageMagickObject is a Windows COM+ interface to ImageMagick. COM+, Visual Basic, and Delphi users should post to this discussion group.
Post Reply
peterpan33

Batch composite with resize

Post by peterpan33 »

Hello,
i use "ImageMagick-6.6.0-10-Q16-windows-dll" (WIN7 64bit) and have created a Batch-file for converting my pics. The Batch-file is in the same lokation as the pics and locks like this:

Code: Select all

@echo on
md druck
FOR /f %%I IN ('DIR *.jpg /b') Do (convert %%I -resize 1477x985 1477x985_%%I)
FOR /f %%I IN ('DIR *.jpg /b') DO (composite %%I d:\AAA1vorlage\vorlage.gif -geometry +950+0 druck\vorlage_%%I)
del 1477x985*.jpg
del druck\vorlage_IMG*.jpg
quit
with the cmd i can use: composite -resize 1477x985 .... (one step)
In the batch-file does it only works with 2 steps. How can i optimise that?
My question: is there a better way to make this operation in 1 Step. I mean composite and resize and without doublemaking image and deleting?
Sorry fpr my English und thx for help.
Peter
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Batch composite with resize

Post by el_supremo »

I'm not clear about what your script is doing but give this a try:

Code: Select all

@echo on
md druck
FOR /f %%I IN ('DIR *.jpg /b') Do (convert %%I -resize 1477x985 d:\AAA1vorlage\vorlage.gif -geometry +950+0 -composite druck\vorlage_%%I)
del druck\vorlage_IMG*.jpg
quit
Pete
P.S. You should have posted this in the Users forum - it has nothing to do with COM or VB.
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
peterpan33

Re: Batch composite with resize

Post by peterpan33 »

Hello,
ok, next time i will post in user forum. Your script do not work! :( . What I want to do with this script is, to put all pics ( are in one directory) on a created postcard (vorlage.gif). So every pic should be with the postcard-background. The pics have different sizes, so first make one size. Then put every pic on the background d:\AAA1vorlage\vorlage.gif and save it in the "druck" directory.
I think my was is not the easy way!
Thanks for your help
Ps.: Maybe an Admin can put me and my problem in the user.forum?
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Batch composite with resize

Post by el_supremo »

Sorry, I forgot that composing with convert requires the filenames in the opposite order , so change the for statement to this:

Code: Select all

FOR /f %%I IN ('DIR *.jpg /b') Do (convert d:\AAA1vorlage\vorlage.gif ( %%I -resize 1477x985 ) -geometry +950+0 -composite druck\vorlage_%%I)
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
peterpan33

Re: Batch composite with resize

Post by peterpan33 »

hello,
sorry but this does also not work. In the cmd you can make it directly with one pic like that:

Code: Select all

composite pic1.jpg -resize 38% d:\AAA1vorlage\vorlage.gif -geometry +950+0 ready.jpg
so you do not need the convert command. But in the batch file it doesnot work? you said it need the opposite order, but i tested everything an it does not work. Maybe some more ideas?
Greetings
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch composite with resize

Post by fmw42 »

you cannot combine steps with composite, but you can combine them with convert and parenthesis processing. convert allows you to use -composite, but the order of images has to be reversed. see

http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/basics/#image_seq

convert backgroundimage ( overlayimage -resize 477x985 ) -geometry +950+0 -composite resultimage

How old is your version of IM. Perhaps it is too old and you need to upgrade?
peterpan33

Re: Batch composite with resize

Post by peterpan33 »

Hi,
my version is "ImageMagick-6.6.0-10-Q16-windows-x64-static"! I think it is a new version! But i use it on a Windows 7 64Bit. Maybe thers is a problem? which is the right version for my OS?

Code: Select all

@echo on
md druck
FOR /f %%I IN ('DIR *.jpg /b') Do (convert %%I -resize 1477x985 1477x985_%%I)
FOR /f %%I IN ('DIR *.jpg /b') DO (composite %%I d:\AAA1vorlage\vorlage.gif -geometry +950+0 druck\vorlage_%%I)
del 1477x985*.jpg
del druck\vorlage_IMG*.jpg
quit
This Batch file works fine on my Computer, but it need a lot power and time, when you have more pics!
There must be a better way?
THX Peter
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Batch composite with resize

Post by fmw42 »

6.6.0 should be OK. try my single command line. to speed things up, you can compile in Q8 rather than default Q16
peterpan33

Re: Batch composite with resize

Post by peterpan33 »

Hello again,
ok this works in the cmd for one pic:

Code: Select all

convert backgroundimage ( overlayimage -resize 477x985 ) -geometry +950+0 -composite resultimage
But I need to convert all pics of one directory. That is the reason, why i use the "for" command with a Batch file. But the "for" Syntax do not work with this code. So how can i use this code to change a lot of pisc?
Thanks a lot
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Batch composite with resize

Post by el_supremo »

I should have realized that the parentheses within the command are causing a problem. The DOS escape character is ^, so try this:

Code: Select all

FOR /f %%I IN ('DIR *.jpg /b') Do (convert d:\AAA1vorlage\vorlage.gif ^( %%I -resize 1477x985 ^) -geometry +950+0 -composite druck\vorlage_%%I)
Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
peterpan33

Re: Batch composite with resize

Post by peterpan33 »

Hey Pete,
thats it! YES! Thanks a lot. Now I have integrated this Batch file on the right mouse click, when I click on a directory. The idea: When you click right on a directory the Batch do his work in this directory.
Like this:

Code: Select all

[HKEY_CLASSES_ROOT\.jpg\Shell\Pics on Background]

[HKEY_CLASSES_ROOT\.jpg\Shell\Pics on Background\Command]
@="\"D:\\AAA1Vorlage\\Batch.cmd\" \"%V\" "
One small problem is still there. It do not work for the directory you have clicked on. It work for the directory, one step over. So for example:
I have a directory: d:\ABC\123!
My pics are in "123", if i click right on "123" and start the Batch, it do the work for the "ABC"!
Small Problem. If you have a solution nice, if not nice. Thanks for your time and your help.
Peter
Post Reply