Is it possible? - The same input and output filename?

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
Axolotl
Posts: 20
Joined: 2010-10-26T11:40:57-07:00
Authentication code: 8675308

Is it possible? - The same input and output filename?

Post by Axolotl »

I couldn't find how to do that. I need to convert a lot of files and i need that filenames of converted files was the same that the file from which it was converted. Is it possible?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible? - The same input and output filename?

Post by fmw42 »

convert image1name .....options.... image1name

This will overwrite the original with all the processing done by the options and keep the same input name. If you want another name just use that for the output. But if you use the same name, the result will write over the input.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: Is it possible? - The same input and output filename?

Post by magick »

Don't forget the mogrify program. It can perform inline image processing and replacement.
Axolotl
Posts: 20
Joined: 2010-10-26T11:40:57-07:00
Authentication code: 8675308

Re: Is it possible? - The same input and output filename?

Post by Axolotl »

Yes, thanks. Mogrify was what i need....i was searching for some hours thru the convert's manuals, that's wy i didn't find anything :D
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Is it possible? - The same input and output filename?

Post by fmw42 »

tg3793
Posts: 6
Joined: 2010-11-19T08:00:56-07:00
Authentication code: 8675308

Re: Is it possible? - The same input and output filename?

Post by tg3793 »

Axolotl wrote:Yes, thanks. Mogrify was what i need....i was searching for some hours thru the convert's manuals, that's wy i didn't find anything :D
<grrr> ... There really should be several references to mogrify in the convert's manual. ... I only searched for about forty-five minutes but it wasn't until I came across this post that I was able to start looking in the right direction.

For the benefit of others this line did exactly what I needed. It took about fifty 2meg to 3meg JPGs (in the same directory) and dropped them all down to 80 to 120 kb. And of course it left all of their names 'exactly' the same.

Code: Select all

mogrify *.jpg -quality 75 -resize "640x480>" *
And, again for the benefit of others:

*.jpg ... performs the mogrify command on all JPGs in the directory.
-quality 75 ... cuts the jpg quality down to 75% which is plenty for online viewing.
-resize "640x480>" ... causes all of the images to be resized to 640x480 (notice the ">" at the end. That makes images smaller but 'not' larger. ... and don't forget the quotes; those are important.
* ... and don't forget this at the very end of the command :-)
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Is it possible? - The same input and output filename?

Post by anthony »

tg3793 wrote:
Axolotl wrote:

Code: Select all

mogrify *.jpg -quality 75 -resize "640x480>" *
That is BAD! You are not just mogrifyign each JOG you are doing so twice, plus any other image you have in the current directory!!!!

Mogrify should only list the file names to modify once, at the end.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
tg3793
Posts: 6
Joined: 2010-11-19T08:00:56-07:00
Authentication code: 8675308

Re: Is it possible? - The same input and output filename?

Post by tg3793 »

Ok, I got that string from another site and it worked so I was pretty excited about.
I'll try to fool with that a bit next time I need to use it for any reason.
Post Reply