Can you resize images and change the DPI at the same time? - RealWorld forums

Log-in or register.

Can you resize images and change the DPI at the same time?

Flip807
on November 30th 2014

My friend and I have been working on a batch script to resize images, change the DPI and transfer the images to a specified location. Now we have it working, it generates the images just fine and in a timely manner but when the script gets to the point of doing the dpi part it slows down the whole process. Is there a way to resize the images and change the dpi of the file on the same pass? Right now we have it doing it in two passes the first is:

start "" /B /BELOWNORMAL "%~dp0PhotoResize.exe" -^200x134 -R -O -U -E -N -Q65 "-c%~dp0\%_event% Generated Images\<PATH>thumb_<name>.jpg" "%~dp0\%event%"

Then the second pass

start "" /B /BELOWNORMAL /wait "%~dp0PhotoResize.exe" -d476 -zthumb_* -t -i -r -u -e -o "%~dp0\%_event% Generated Images"

Not to sure if they can be combined into one pass or not. Any input would be appreciated.

-flip807

Vlasta
on November 30th 2014

IT is currently not possible to do in one step, but since it is one of the most often question, I'll be adding it in the future. Right now, the change of DPI step should be relatively fast as it only overwrites the numbers in the header of each. Are there any old thumb_* images in the target folder?

Flip807
on November 30th 2014

Yes, the way the images are stored is there's the main folder and within that there's about 300 subfolders which is where the images are going into. Each of those folders can contain from 150 to 500 images. The images are coming in through out the whole day, so the script is supposed to monitor, generate, change the dpi and then transfer the files to another location. The reason we need the dpi changed is because when we print thumbnails for some reason it bases the size of the thumbnail from the dpi. Could it be slowing down at that point because it has to verify all the files first?

Vlasta
on November 30th 2014

If there are many old files, then I would say the -u (only process files not in the destination folder) and -i (in place resizing) could be the problem, because the -u must be ignored (or else nothing would be processed). So everything is processed every time. Maybe use a temporary folder between the steps.

Flip807
on December 1st 2014

So we decided to add another step to the process and changed the script. We changed it to this.

start "" /B /BELOWNORMAL /wait "%~dp0PhotoResize.exe" -d476 -zthumb_* -t -i -r -u -e -o "-cC:\Share\%_event% Generated DPI Images\<PATH><NAME>.jpg" "C:\Share\%_event% Generated Images"

Now we are trying to take the generated images and run the dpi pass and have it dump to a new folder but the changes that we have done seem to break the code. We thought that this part of the script would now pull from the Generated Images folder and dump into a whole new folder Generated Dpi Images.

Vlasta
on December 1st 2014

You need to drop the -i

Flip807
on December 2nd 2014

So we dropped the -i and tested the scrip again and when it gets to the dpi portion of the script it hangs for less than a min and it moves on. When we checked to see if the dpi part worked we found that when it was hanging it actually didn't even open the PhotoResize.exe. But it didn't throw a error or freeze up the script. Any ideas why it wouldn't open the PhotoResize.exe? I've ran the Dpi part of the script without it creating a new folder, basically just pointing it to a folder to process and it does around 72 folders in about 5 to 7 seconds. Any ideas?

Page views: 2877       Posts: 7      
Select background
Vista & Win 7 icons
I wish there were...