Page 1 of 1
(newbie)need a automated bat file but stuck.
Posted: 2010-01-28T02:21:32-07:00
by ricky ricardo
Hope somebody can help me out on something
I have 2 folders that have images.
folder 1 has 496 x 720 images
folder 2 has the 1280 x 720 images
so i used -gravity west -composite on 1 named image and it works but how do i automate it without using names of that image?
I want every image off folder 2 to get the image from folder 1 making the new image in folder 2.
Hope somebody can help me out on this
EXAMPLE:
Code: Select all
convert.exe pictures/folder2/8738843.jpg pictures/folder1/8738843[LEFTSIDE].png -gravity west -composite 8738843.jpg
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-28T10:56:56-07:00
by fmw42
I think you need to use full paths from c:\ and use backslashes (unless you are using cygwin-like unix). I am not a windows user, so any Windows expert, please correct me.
P.S. there is no such thing as [LEFTSIDE] in IM. You will need to find the [WidthxHeight+xoffset+yoffset]
see selecting an image region at
http://www.imagemagick.org/script/comma ... essing.php
or
-crop at
http://www.imagemagick.org/script/comma ... s.php#crop
or
http://www.imagemagick.org/Usage/crop/#crop_repage
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-28T11:13:06-07:00
by ricky ricardo
hey thnx for the reply but im using windows
&[LEFSIDE].png is the name off the imagefile and when using gravity west the image is the way i want it.
I only need it for more images really.
so something recursive but how? & keeping the name.jpg
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-28T11:17:08-07:00
by fmw42
sorry i am not a Windows user
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-29T11:06:43-07:00
by ricky ricardo
thats a shame but how will i go about it on unix?
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-29T15:45:11-07:00
by fmw42
you will need to write a loop over each image name found in both folders and composite them together into one or the other folder or even a different folder. The unix command will not look anything like what you do in DOS, so perhaps some Windows user can come to your rescue.
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T02:37:26-07:00
by Bonzo
I had a go at batch files last year but have basicly forgotten most of it as I only use a simple file myself.
This may help you out:
Code: Select all
::Modify a whole directory of images
::Read a directory and modify all jpg images
::Turn of displaying the code on the screen
@echo off
:: Read all the jpg images from the directory, resize them, add some text and save as a png in a different directory
for %%f in (%1\*.jpg) do ( convert %%f -resize 200x200 -pointsize 18 -fill black ^
-gravity northwest -annotate +0+0 "Some text" "%2\%%~nf.png" )
::This batch file was named resize.bat and called using "resize path\to\original\ path\to\save"
Some other examples:
http://www.rubblewebs.co.uk/imagemagick/batch.php
You should be able to make your batch file from the examples here.
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T02:46:30-07:00
by ricky ricardo
Big Thnxx but then my newbie side will pop up.
I dont need any risizing so i can remove the parts?
Am i In the right direction?
Code: Select all
::Modify a whole directory of images
::Read a directory and modify all jpg images
::Turn of displaying the code on the screen
@echo off
:: Read all the jpg images from the directory, resize them, add some text and save as a png in a different directory
for %%f in (%1\*.jpg) do -gravity west -annotate +0+0 "" "%2\%%~nf.png" )
::This batch file was named resize.bat and called using "resize path\to\original\ path\to\save"
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T03:11:34-07:00
by ricky ricardo
let me say it different.
i get the gravity part but cant get the right directories & where i put it on you're example.
::pictures/folder2/8738843.jpg
::pictures/folder1/8738843[LEFTSIDE].png
-gravity west -composite 8738843.jpg
but need to add a bat file on folder1 & folder 2?
hope you can help me out because doing this manual will take like forever
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T06:00:47-07:00
by Bonzo
Yes you can change the convert part to what you want.
From memory to run my example posted you need to:
Name the file resize.bat and save it on your desktop
Find the path to the images to modify e.g. C:\Users\Anthony\Pictures
Find the path to save to e.g. C:\Users\Anthony\Pictures\modified
Open up the comand prompt and input: resize C:\Users\Anthony\Pictures C:\Users\Anthony\Pictures\modified
The last example on my site is anotherway of doing it but you need to setup some paths etc. in the bat file.
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T06:14:42-07:00
by Bonzo
I have just tried this code and there seems to be some problems. For a start the convert is missing and it will not run on Vista.
I am afraid that I do not have time to look into it at the moment.
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T08:25:49-07:00
by ricky ricardo
I got this but it gives a error
convert:missing an image filename
Code: Select all
for %%f in (pictures\folder2\%1\*.jpg) do (convert %%f ^
-gravity west -composite -annotate +0+0 "" "pictures\folder1\%2\%%~nf[LEFTSIDE].png" )
PAUSE
it scans...
so one step closer but it needs to replace the folder2 images but convert:missing an image filename are some off the errors i get
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T08:31:52-07:00
by el_supremo
Try this:
Code: Select all
::Modify a whole directory of images
::This assumes that you are in the directory pictures\folder2 so you only have to specify the
:: path to folder1. The result will be in folder2.
:: Name this batch file as resize.bat and call it using "resize path\to\folder1"
:: For example, if you are in folder2 you could use "resize ..\folder1"
::Turn off displaying the code on the screen
@echo off
for %%f in (*.jpg) do ( convert "%%f" "%1\%%~nf[LEFTSIDE].png" -gravity west -composite "%%~nf.png" )
Pete
Re: (newbie)need a automated bat file but stuck.
Posted: 2010-01-30T12:16:47-07:00
by ricky ricardo
ohh yess it worked so thnx all for helping me out on this!!!