Stitching image on given canvas size ? [SOLVED]

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

If I type:

"c:\program files\imageMagick-6.8.3-Q16\identify" -version


It outputs:

Versin: ImageMagick 6.8.3-6 2013-02-26 Q16 http://www.imagemagick.org
Features: DPC OpenMP
Delegates: bzlib fontconfig freetype jng jp2 jpeg lcms lzma pango png ps tiff x xml zlib
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Stitching image on given canvas size using ImageMagic ?

Post by snibgo »

That directory can be added to your path, so programs there will be found without having to give their location every time. Type:

Code: Select all

set PATH=c:\program files\imageMagick-6.8.3-Q16\;%PATH%
This adds the directory to the path for this command window only. Try the commands and script now.

To make the change system-wide: Control panel, System, Advanced, Evironment variables, System variables. Or you can reinstall IM and let it do the job for you.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

Ok, after reinstalling it seems to work now.

Is there a way to have that batch script process multiple files at a time ? E.g. all gifs in one folder and output them to another folder, numbered 001 002 etc. ?
Last edited by Rye on 2013-02-28T14:03:29-07:00, edited 3 times in total.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Stitching image on given canvas size using ImageMagic ?

Post by snibgo »

Yes. See any guide on scripting in Windows.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

[deleted]
Last edited by Rye on 2013-03-03T07:02:22-07:00, edited 1 time in total.
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

EDIT: There is a really simple way that all those images have in common:

Their pattern repeats after EXACTLY 128x128 pixels.

Could you please change your script to work for those files only ? That would reslove this problem and this thread could be closed.

Thanks for all you assistance. It was of great help to me !

:D
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

I know got this one working:

Code: Select all

SET /P width=Please enter canvas width:
SET /P heigth=Please enter canvas heigth:
convert *.gif -crop 128x128+0+0 cropped.png

"%IMG%convert" ^
  -size %width%x%heigth% ^
  tile:cropped.png ^
  tiled.png
However the problem is that I want this script to process 100+ gifs inside the same folder.

If I currently put it in the folder it will only output some croped-X.png's and quit.

It should be able to process each gif after the other.

Ideas ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Stitching image on given canvas size using ImageMagic ?

Post by fmw42 »

convert *.gif -crop 128x128+0+0 cropped.png
With PNG you need to remove the virtual canvas by adding +repage after the crop.

Furthermore you process all the gifs as cropped-xxx.png, but you only use cropped.png in your next command.

I do not believe that you are looping correctly or I do not understand what you are trying to do. Sorry I am not a Windows user, so cannot help much more at this point without further explanation.
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

I only need 1 cropped.png for the output file.
1 cropped.png -> tiled.png

Well that script aside:

The only thing I try is:

Process input file (001)
- save to outputfile that matches the 001 of the input and add a -output to it

Repeat with 002...

You could say "lets not care about the script at all right now" the only thing that matters is to find a way to process all gifs in the folder and then afterwards have the output correlate to the same number.


Wait a minute now thats an idea... when I processed all those images to lets say... cropped-0.png, cropped-1.png ...

What would I have to do then in order to get the rest working ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Stitching image on given canvas size using ImageMagic ?

Post by snibgo »

"convert *.gif" will read all the gifs before processing any of them. Maybe not a great idea.

For looping through files, see Windows "for" command. You could have two converts within the for-loop: one to crop, the second to tile. (Or even do both jobs in one convert.)
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

After some fiddling around I got this far:

Code: Select all

for %%X in (*.png) do "%IMG%convert" ^
-size 612x322 ^
tile:%%X ^
tiled.jpg
The problem now however is that I only have one tiled jpg.
How can I achieve that the tiled will be automatically numbered so I have it like this: 001tiled.jpg 002tiled.jpg..... ?
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Stitching image on given canvas size using ImageMagic ?

Post by snibgo »

That would be quite tricky. But you can easily do:

Code: Select all

for %%X in (*.png) do "%IMG%convert" ^
-size 612x322 ^
tile:%%X ^
%%~nX_tiled.jpg
Type "for /?" or "help for" for this and other options.
snibgo's IM pages: im.snibgo.com
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

ok, that works great !
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Rye
Posts: 158
Joined: 2013-02-25T10:43:05-07:00
Authentication code: 6789

Re: Stitching image on given canvas size using ImageMagic ?

Post by Rye »

Since this problem is resolved the thread can be closed !

Thank you very much again for your extensive and effective help !
Version: ImageMagick-7.0.7-28-Q16-x64-static http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
Post Reply