Image resizing via .bat file

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?".
Post Reply
stvofficial
Posts: 6
Joined: 2016-05-12T08:10:55-07:00
Authentication code: 1151

Image resizing via .bat file

Post by stvofficial »

Hello everyone!
Can you help me with code, that will resize image to 1440*1440 px? Thanks!
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image resizing via .bat file

Post by fmw42 »

What do you want to happen if the input image is not square? Imagemagick can force the output to be square, but that may distort the image if it was not originally square. So you need to decide if you want to crop or pad. See the sections below http://www.imagemagick.org/Usage/thumbnails/#creation.

Please always provide your IM version and platform? We assume you are on Windows if you mention .bat files.

Please read the very top-most post on this forum at viewtopic.php?f=1&t=9620 IMPORTANT: Please Read This FIRST Before Posting
stvofficial
Posts: 6
Joined: 2016-05-12T08:10:55-07:00
Authentication code: 1151

Re: Image resizing via .bat file

Post by stvofficial »

All the time I gona have square images for resize.
I'm using "ImageMagick-7.0.1-Q16".
My platform is Windows.
stvofficial
Posts: 6
Joined: 2016-05-12T08:10:55-07:00
Authentication code: 1151

Re: Image resizing via .bat file

Post by stvofficial »

fmw42 wrote:What do you want to happen if the input image is not square? Imagemagick can force the output to be square, but that may distort the image if it was not originally square. So you need to decide if you want to crop or pad. See the sections below http://www.imagemagick.org/Usage/thumbnails/#creation.

Please always provide your IM version and platform? We assume you are on Windows if you mention .bat files.

Please read the very top-most post on this forum at viewtopic.php?f=1&t=9620 IMPORTANT: Please Read This FIRST Before Posting
All the time I gona have square images for resize.
I'm using "ImageMagick-7.0.1-Q16".
My platform is Windows.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image resizing via .bat file

Post by fmw42 »

The basic command is

Code: Select all

magick image -resize 1440x1440 result
If you want to resize all images in a folder, then

Code: Select all

magick mogrify -resize 1440x1440 *
but that will overwrite your input images. So create a new empty directory and add -path path2/newdirectory to put the output in that directory. See http://www.imagemagick.org/Usage/basics/#mogrify

Sorry, I am not a Windows user and only script in unix bash shell.
stvofficial
Posts: 6
Joined: 2016-05-12T08:10:55-07:00
Authentication code: 1151

Re: Image resizing via .bat file

Post by stvofficial »

fmw42 wrote:The basic command is

Code: Select all

magick image -resize 1440x1440 result
If you want to resize all images in a folder, then

Code: Select all

magick mogrify -resize 1440x1440 *
but that will overwrite your input images. So create a new empty directory and add -path path2/newdirectory to put the output in that directory. See http://www.imagemagick.org/Usage/basics/#mogrify

Sorry, I am not a Windows user and only script in unix bash shell.
It says to me that: "magick: unable to open image 'image': No such file or directory @ error/blob.c/OpenBlob/2691."
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image resizing via .bat file

Post by fmw42 »

You have to insert your own "image" path and filename there and specify your own "result" path and filename

For new users, see:

http://www.imagemagick.org/script/comma ... essing.php
http://www.imagemagick.org/Usage/
http://www.imagemagick.org/Usage/reference.html

and for windows users

http://www.imagemagick.org/Usage/windows/
stvofficial
Posts: 6
Joined: 2016-05-12T08:10:55-07:00
Authentication code: 1151

Re: Image resizing via .bat file

Post by stvofficial »

fmw42 wrote:You have to insert your own "image" path and filename there and specify your own "result" path and filename
Ah damn, thanks :D

One more question - is anyway to paste image on image? Thanks
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Image resizing via .bat file

Post by fmw42 »

If you want to overlay one image onto another, see

http://www.imagemagick.org/Usage/layers/
http://www.imagemagick.org/Usage/compose/

Code: Select all

magick backgroundimage foregroundimage -gravity XX -geometry +X+Y -compose over -composite resultimage
see
http://www.imagemagick.org/script/comma ... hp#gravity
http://www.imagemagick.org/script/comma ... p#geometry

See my links above also
stvofficial
Posts: 6
Joined: 2016-05-12T08:10:55-07:00
Authentication code: 1151

Re: Image resizing via .bat file

Post by stvofficial »

fmw42 wrote:If you want to overlay one image onto another, see

http://www.imagemagick.org/Usage/layers/
http://www.imagemagick.org/Usage/compose/

Code: Select all

magick backgroundimage foregroundimage -gravity XX -geometry +X+Y -compose over -composite resultimage
see
http://www.imagemagick.org/script/comma ... hp#gravity
http://www.imagemagick.org/script/comma ... p#geometry

See my links above also
Thanks a lot!
Post Reply