Page 1 of 1
Output file name
Posted: 2018-01-17T08:00:20-07:00
by Thrandur
I am creating thumbnails from images using this comman:
convert * -thumbnail 200x200^ -gravity center -extent 100x100 thumbs/*.png
The output is just as expected
In the source folder there are two files a.png and b.jpg and in the output folder the corresponding thumbnails created are a-0.png and a-1.png.
How can I keep the original filenames - and without the numbering?
Re: Output file name
Posted: 2018-01-17T08:31:24-07:00
by GeeMack
Thrandur wrote: ↑2018-01-17T08:00:20-07:00How can I keep the original filenames - and without the numbering?
It looks like "mogrify" might be the right tool for what you're trying to do. Try this...
Code: Select all
mogrify -thumbnail 200x200^ -gravity center -extent 100x100 -path thumbs *.png
Make sure the directory "thumbs" already exists.
Re: Output file name
Posted: 2018-01-17T09:03:09-07:00
by Thrandur
Brilliant !
But now I have a new problem...
...this worked for 66 files out of about 15K!
Running on Windows 10
Would it be better on the Hosting server?
Re: Output file name
Posted: 2018-01-17T10:13:44-07:00
by GeeMack
Thrandur wrote: ↑2018-01-17T09:03:09-07:00Brilliant !
But now I have a new problem... ...this worked for 66 files out of about 15K!
I don't understand your issue. What sort of error do you get when the "mogrify" command stops running? Also, please let us know which version of ImageMagick you're using.
Re: Output file name
Posted: 2018-01-17T11:27:30-07:00
by Thrandur
That is the strange part - no error message.
identify -version
Version: ImageMagick 7.0.6-10 Q16 x64 2017-08-27
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2015 ImageMagick Studio LLC
License:
http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenMP
Delegates (built-in): bzlib cairo flif freetype jng jp2 jpeg lcms lqr openexr pangocairo png ps rsvg tiff webp xml zlib
Re: Output file name
Posted: 2018-01-17T14:31:55-07:00
by GeeMack
Thrandur wrote: ↑2018-01-17T11:27:30-07:00That is the strange part - no error message.
Some things I'd consider would be files IM can't read for some reason, or can't write to, permissions, etc. I'd still expect a warning or error message. Maybe a corrupt input file if it always stops at the same place. Put that 67th image aside and test it alone. I'd also maybe check if there's no space left on the drive or a quota is filled or something similar. I'd still expect some kind of warning messages, so it's a mystery.
There is a newer version of IM available, so maybe there's a bug in the version you're using.
Check this link for updates.
I don't know much about the internal workings of the program, so maybe some other folks on the forum here can offer other simple – or not – suggestions.
Re: Output file name
Posted: 2018-01-17T17:18:31-07:00
by Thrandur
Thanks GeeMack
A corrupt file could be the cause, but then I have to find out in what order the files are processed by IM or even better the actual file that causes trouble.
An update didn't help
Re: Output file name
Posted: 2018-01-17T17:22:11-07:00
by fmw42
Imagemagick uses the file system to list images to process, which is typically alphabetic order (same as typically is displayed by your OS)
Try adding -print "%f\n" to your mogrify command to get it to list the filenames in order processed to the terminal (or redirect to a file)
Code: Select all
mogrify -thumbnail 200x200^ -gravity center -extent 100x100 -path thumbs -print "%f\n" *.png
Re: Output file name
Posted: 2018-01-18T13:19:43-07:00
by Thrandur
Thanks all
This has been an interesting journey of discovery - so I wanted to share some steps:
//Step 1 - List files and find corrupt
identify -regard-warnings *.* >log.txt 2>&1
//Step 2 - Delete corrupt files and file formats you don't plan on using
//Step 3a - Generate thumbnails + list files
mogrify -thumbnail 200x200^ -gravity center -extent 100x100 -print "%f\n" -path thumbs *.png
//Step 3b - Generate thumbnail - all jpg
FOR %a in (*.jpg) DO mogrify %a -thumbnail 200x200^ -gravity center -extent 100x100 -print "%f\n" -path thumbs %a
Generating using the FOR loop seems to work the best, looping over each format in turn.
Re: Output file name
Posted: 2018-01-18T13:30:43-07:00
by Bonzo
Off topic: I see you have made use of -print now fmw42
Re: Output file name
Posted: 2018-01-18T14:22:56-07:00
by fmw42
Bonzo wrote: ↑2018-01-18T13:30:43-07:00
Off topic: I see you have made use of -print now fmw42
I had to, since -format would have to be used twice, once for the file format and the other for the filename. So I just tried using -print rather than -format "%f" -write info:. To my surprise, -print worked in mogrify.