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?".
%~d1
CD "%~p1"
MD upsized
FOR %%a in (*.jpg) DO (
convert %%a -resize "2400^<" upsized\%%a
)
PAUSE
It successfully upsizes all of the small images, but also modifies all of the images that are already large enough (they stay the same resolution, but are compressed).
Your images are probably getting decompressed and then recompressed if you are resaving them as jpg, so you lose quality. Also the quality may not be as high as you started unless you specify the -quality value you want.
Your images are probably getting decompressed and then recompressed if you are resaving them as jpg, so you lose quality. Also the quality may not be as high as you started unless you specify the -quality value you want.
I'm pretty sure that's what's happening, which is why I want to bypass (just skip them) any images that are already large enough - is there any way to do that?
With your command line, IM will not resize them but will decompress and recompress the jpgs. I don't know any way to avoid IM processing even to read and write it again, except to write a script to compute the image sizes or what not and skip processing them altogether. But perhaps one of the IM developers may have other suggestions.
[quote="arcking"It successfully upsizes all of the small images, but also modifies all of the images that are already large enough (they stay the same resolution, but are compressed).[/quote]
Hmmm it may be that the 'abort' on resize does not preserve the 'taint' flag of the image.
But then I am not certain taint actually aborts a write to the same image.
Hmm quick test using PNG images says it always over writes the image.
fmw42 wrote:With your command line, IM will not resize them but will decompress and recompress the jpgs. I don't know any way to avoid IM processing even to read and write it again, except to write a script to compute the image sizes or what not and skip processing them altogether. But perhaps one of the IM developers may have other suggestions.
I was thinking I might have to use a script...any suggestions on what I should do the scripting in?
Am I correct in my understanding that any modification done to a JPEG is lossy? In other words, even if I rewrite the file with "-quality 100" it will have lost some (minute) level of detail (compared to the original). Ultimately a script will probably prove to be worthwhile considering that it's going to have to process over 300,000 images and that I can specify a minimum size that is different from what they'll be resized to.
arcking wrote:[
I was thinking I might have to use a script...any suggestions on what I should do the scripting in?
Am I correct in my understanding that any modification done to a JPEG is lossy? In other words, even if I rewrite the file with "-quality 100" it will have lost some (minute) level of detail (compared to the original). Ultimately a script will probably prove to be worthwhile considering that it's going to have to process over 300,000 images and that I can specify a minimum size that is different from what they'll be resized to.
Yes, as far as I know jpeg even with -quality 100 with still give some loss. You could use the lossless JP2000 from the jasper library or some other lossless image format, but then the file size will likely be larger.
I script in bash unix. That is pretty much all I know. But you have many options for IM APIs as well.
Here is an example:
#/bin/bash
cd yourdirectory
list=`ls`
for name in $list; do
area=`convert $name -ping -format "%[fx:w*h]" info:`
if [ $area -lt 100000 ]; then
echo "$name $area"
fi
done
SET minsize=2925
SET newsize=3000
SETLOCAL ENABLEDELAYEDEXPANSION
FOR %%A in (*.jpg) DO (
ECHO %%A
FOR /F "tokens=* delims=" %%B in ('convert %%A -ping -format %%w info:') Do (
SET width=%%B
)
FOR /F "tokens=* delims=" %%B in ('convert %%A -ping -format %%h info:') Do (
SET height=%%B
)
IF !width! LSS %minsize% (
IF !height! LSS %minsize% (
ECHO: - Resized
ECHO "%%A","Resized" >>upsized\Resize_log_file.csv
convert %%A -resize %newsize%x%newsize% upsized\%%A
)
)
ECHO.
)
PAUSE