Announcement

Collapse
No announcement yet.

Fit image with white to reach specific dimensions

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Fit image with white to reach specific dimensions

    Hi

    I'm interested in using irfanview in order to elaborate tons of images. This is what I need:

    1.
    I have a folder with images of different width and height.
    I want to define a minimum width and a minimum height. If an image has one between width or height lower than these minimum values, "white background" should be added to image in order to fit those values.
    So if minimum width and a minimum height are 500x500 and an image is 1200x300, software should add white above and under image untill it covers 500px (it adds 100px above and 100px under)
    if an image is 150x200, software should add white around image (350px for width and 300 for height). so final w and h will be 500x500

    2.
    Some thing of point 1 but with the difference that final width of image must be the one I define. So an image of 1200x300 will be resized to 500x500 adding white where necessary. In my mind this means that white is added above and under original image till a width of 1200, and then image is resized to 500x500

    is this possible with a batch of IV?

    Thanks

    #2
    If I understand what you want for requirement 1 you just set Canvas size, Method 2 to 500x500 pixels, centered.
    For requirement 2 you first need to resize to 500x500 pixels while preserving aspect ratio and then change the Canvas size as above.
    Click on the thumbnail below to see the settings for 2. For 1 leave Resize unchecked.

    Click image for larger version

Name:	Resize and canvas.png
Views:	1
Size:	47.9 KB
ID:	81459

    Comment


      #3
      Hi Mij and thanks for your reply

      it seems to do exactly what I need. I used also "don't enlarge smaller images".

      Is there a way to "translate" this batch into a batch file?

      thanks

      Comment


        #4
        Originally posted by Yep View Post
        Is there a way to "translate" this batch into a batch file?
        Yes. You need to use Command Lines in the batch file and those that Irfanview supports can be found in the Help file (Open Irfanview, press F1 and select Overview > Command Line Options).

        You will see that /Resize is supported as a direct command line option but not /Canvas, so you will need to use /Advancebatch instead. For this you need to set up the advanced batch features you want in Irfanview just as you did it above, and then close Irfanview. All your settings will be saved in the Irfanview initialisation file and will be applied to the image conversion when you run your Batch file.

        I do not know how familiar you are with Batch files. You are welcome to ask general questions about them here but if you want detailed help to write one you should go to the "Command line and Scripts" section of the Forum and ask your questions there.

        Comment


          #5
          Hi Mij

          I'm familiar with batch file
          I've already done a batch file for resizing and it works perfectly

          Now I have another question:
          Imagine to have an image of a pen. This pen is diplayed vertically. The original image is squared, so there is a lot of white background on the left and right. Is it possible to remove all white background around the pen?

          thanks

          Comment


            #6
            Yes, possibly. It depends on how much color range there is in the "white" background. If it was originally added as a single color border, similar to what we were discussing previously, then all you need do is set "Auto crop borders". If it is a photo and the background is just "white-ish" it will contain a range of colors and then Auto crop borders will not work. You could try "Replace color" first to see if there is a tolerance value that you can set which would let you convert the range of whites to a single one. Then Auto crop borders can be used.
            I assume that you still want to do this in a batch process for a lot of images. If it is a one-off, using the color replace tool in the Paint plugin gives you a lot more control.

            Comment


              #7
              Hi

              Everything worked perfectly with batch processing

              Now I have another problem. I need to set a maximum size for some images, for example 700x700.

              Every image bigger than these is cropped and then resized to 700x700 with canvas 700x700

              But for smaller images the need is different. If an image is 50x30, I don't want to resize and canvas it to 700x700 because final image will have the subject in center and lot of white around.

              For images smaller than 700x700 I need only to crop and then canvas with a dimension that is equal to the bigger between width and height of the original image. This is a problem related to visualization of images on mobile devices. If there is lot of white around on mobile, visualization is very bad.

              Is this possible?

              thanks

              Comment


                #8
                I think now you are going beyond what is possible. You really need to process the smaller than 700x700 images separately with different Advanced batch options.

                Since you have not filled in your profile I do not know what Windows version you are using.
                This is what I can do in Windows 10;
                1. Open the Irfanview Batch conversion dialog. Remove any old files from the "Input files" pane.
                2. Open File Explorer (the replacement for Windows Explorer). Find the folder I want to process and from the View menu choose "Group by dimensions"
                3. Click on the title for the Group containing the smallest images e.g (50x30). This will highlight all the images in that group.
                4. Hold down the shift key and click on the title for the Group containing the largest images less than 700x700 e.g. (620x680). All the images less than 700x700 should now be selected.
                5. Click on one of the highlighted images and drag and drop it on the "Input files" pane of the Irfanview Batch dialog. All the highlighted images should now be listed in the dialog pane.
                6. Select the Batch conversion Advanced settings for this batch of files (I could have them all pre-saved in a file using the Custom processing order feature if I wanted).
                7. Run the batch.
                8. Remove All from the Input files pane and drag in all the files over 700x700 from File Explorer. Process that batch with whatever settings are needed for those.

                Comment

                Working...
                X