batch-fileirfanview

How to resize image with same width and height without quality loss using IrfanView?


I use IrfanView in batch mode to resize my images. I want to resize all image to a width of 1840 pixels without ratio and quality loss.

For example if I have one image with 1700 x 1700 pixels and resize it to 1840 x 1840 pixels there is no problem. The quality is okay.

But the problem is on resizing an image with 1920 x 1200 pixels as the height is much smaller than the width.

The executed command is:

"C:\IrfanView\i_view32.exe" "C:\photo\C0692B\*.jpg" /resize=(1840, 1840) /resample /convert="C:\photo\C0692B\test\*.jpg"

I lost quality for height. I don't want resize height because it is lower than the wanted size.

Before command:
http://www.hostingpics.net/viewer.php?id=714806photo2.jpg
After:
http://www.hostingpics.net/viewer.php?id=445086photo2.jpg

For this example I want to center image and add blank to obtain an image with 1840 x 1840 pixels without a quality loss.

How to do this?


Solution

  • The text file i_options.txt in program files folder of IrfanView lists and explains all options supported by IrfanView on the command line.

    It looks like you want to resize each JPEG image in a folder to a width of 1840 pixels with keeping aspect ratio for images in landscape format, i.e. width is higher (or equal) than height.

    For images in portrait format it is most likely better to resize the height to 1840 pixels with keeping the aspect ratio of each image.

    There are the options /resize_long=x and /aspectratio for this purpose.

    "C:\IrfanView\i_view32.exe" "C:\photo\C0692B\*.jpg" /resize_long=1840 /aspectratio /resample /convert="C:\photo\C0692B\test\*.jpg"
    

    An image with 1920 x 1200 pixels has an aspect ratio of 1920 / 1200 = 1.6 and therefore the resized image has 1840 x 1150 pixels.

    I do not recommend to resize each image with a too low height or width to 1840 x 1840 pixels to get only square images with "blank" area on top and bottom side on an image with a too low height or "blank" area on left and right side on a too small width.

    If the images are needed for a web gallery in 1840 x 1840 pixels, reference each image from within a DIV or TD element with a width and height of 1840 pixels and define that the image is displayed centered horizontally and vertically within the element.

    However, it is also possible to proportional resize images to 1840 x 1840 pixels with canvas the resized image for example with white border on top/bottom or left/right depending on width and height of original image using advanced batch conversion mode.

    I clicked first inside IrfanView in menu File on menu item Batch Conversion/Rename.

    Then I enabled Use advanced options (for bulk resize...) and clicked on button Advanced.

    I did following in the opened large dialog window:

    All other advanced options are not checked.

    The JPG options set by me:

    All other JPG options are not checked.

    All those settings are written to i_view32.ini and can be used with /advancedbatch from command line.

    I decided to find out how all these options are saved in INI file of IrfanView to be able to write a batch file which creates dynamically i_view32.ini in folder for temporary files for the batch image conversion task. This has the advantage of being independent on what by default used i_view32.ini currently contains on settings.

    The batch code:

    @echo off
    (
        echo [Batch]
        echo AdvCanvas=1
        echo AdvResample=1
        echo AdvResize=1
        echo AdvResizeRatio=1
        echo AdvResizeH=1840.00
        echo AdvResizeW=1840.00
        echo AdvSaveOldDate=1
        echo AdvOverwrite=1
        echo UseAdvanced=1
        echo UseResample=1
        echo\
        echo [Effects]
        echo CanvMethod=1
        echo CanvInside=1
        echo CanvW=1840
        echo CanvH=1840
        echo CanvCorner=4
        echo CanvColor=16777215
        echo\
        echo [JPEG]
        echo KeepCom=1
        echo KeepExif=1
        echo KeepIptc=1
        echo KeepQuality=1
        echo KeepXmp=1
        echo Save Progressive=1
        echo Save Quality=95
    ) >"%Temp%\i_view32.ini"
    
    "C:\IrfanView\i_view32.exe" "C:\photo\C0692B\*.jpg" /ini="%Temp%" /advancedbatch /convert="C:\photo\C0692B\test\*.jpg"
    
    del "%Temp%\i_view32.ini"