Announcement

Collapse
No announcement yet.

Can you resize an image to an exact size, retain aspect, and fill any space?

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

    Can you resize an image to an exact size, retain aspect, and fill any space?

    Let's say I want to convert an image to an exact size, eg: 400x300. The trick is, if the image, due to its aspect ratio, does not fit in 400x300, then place it in there with black borders.

    A 900x1200 image would be converted down to 225x300 to retain its aspect ratio, and then given black borders left and right to make it 400x300.

    A 1200x600 image, would be converted down to 400x200, and given black borders top and bottom to make it 400x300.

    #2
    I'm afraid that two steps are needed here.
    1. First resize the image according to the aspect ratio.
    2. Use 'Change Canvas size' (Shift+V) and calculate the remaining border size on each side filled with the chosen color.
    Of course the order 2 - 1 would do as well.

    Edit :
    It appeared that this can be done in one action with the Batch conversion ("B")
    Go to 'Advanced', set the resizing, and change the Settings of the Canvas size.
    0.6180339887
    Rest In Peace, Sam!

    Comment


      #3
      Originally posted by Sam_Zen View Post
      It appeared that this can be done in one action with the Batch conversion ("B")
      Go to 'Advanced', set the resizing, and change the Settings of the Canvas size.
      Many thanks. But I'm trying to do this in command line mode? I can't see any command line options to achieve that though

      Comment


        #4
        Drat, no, there doesn't seem to be any. Looks like a good feature request. I think a lot of people would like this.
        Its: Belongs to "It"
        It's: Shortened form of "It is"
        ---------------------
        Lose: Fail to keep
        Loose: Not tight

        ---------------------
        Plurals do not require apostrophes

        Comment


          #5
          Yep, I searched the command line options before my answer, and couldn't find any.
          A request worth indeed. I suppose any option in the batch dialog should be represented in the command options as well, also combined.
          0.6180339887
          Rest In Peace, Sam!

          Comment


            #6
            Any work on this feature by any chance? I almost posted a new thread could I couldn't quite find the right keywords for this. This would be an excellent feature for me because I'm changing a bunch of pictures to work as wallpaper for my HTC EVO but each picture varies in dimensions. The black borders would not bother me at all.

            A batch function for this would be awsome as well so I don't have to do it to each of the pictures.

            Comment


              #7
              Are the images that you want to create smaller than your screen size (like those that the OP wanted to create)? If so you might consider using a screen capture.

              You would need to set up the Irfanview Display option to Fit images to window and Center in window and hide the Toolbar and Status bar by pressing Alt+Shift+T and Alt+Shift+S since these would otherwise be included in the area that you are going to capture. Also set the Main window color in Properties/Settings> Viewing to whatever you want as background.
              Next you need to set the size of the window to match what you want to capture. You need to allow for the frame and the caption and menu bars, so the window has to be 16 pixels wider and 56 pixels higher than the image that you want. Easiest way is to edit the Width and Height in the [WinPosition] section of your i_view32.ini file to what you need.

              Next open Irfanview and set up Capture from the Options menu. Select 4 Foreground window -client area and choose whether you want to Show in main window and save manually or Save captured image as a file. You probably do not want to Include the mouse cursor so uncheck that. Make a note of the Hot key you are going to use to capture and press Start. The window will minimize to the Task bar but just click on it there to open it up again.

              Now open your first image, which will appear fitted as you want it in the window, and press the Hot key to capture everything in the window including the unfilled background. If you have all your images in one folder, I think you will find it quite quick to go through them all.

              It is not perfect. You do capture a little bit of the bevel at the edges of the window but it may be good enough for what you want.

              Comment


                #8
                It isn't so bad if I had a small handful of images but i have quite a few so it becomes a bit painful. I would actually like to preserve the size of the picture but have the blank border(s) be added to meet a specified ratio. For example the HTC EVO's wallpaper is 960x800 with a ratio of 1.200. Say I have a picture, for example, that is 1427x568 with a ratio of 2.513. In order to meet the 1.200 requirement, basically a border needs to be added to the image's side (top, bottom, left and/or right).

                I'm not an advanced user of this program but what I've been doing for this example is I would have irfan set to fit image to the desktop (the F button) use the "change canvas size" (shift+v) option and add like 1000 to the top and bottom. Then I would use Ctrl+A to select all then adjust the top and bottom selection field to equal 1.200 then using right click to adjust that selection field up and down until I'm relatively happy with the selection. Finally crop the picture (ctrl+Y then save). The end result is what I pretty much get in the attachment. This is similar to doing a "Option" > "Set as wallpaper" > selecting Stretched (proportional) one one's wallpaper but restricted to a ratio and then saving it as a file.

                Batching something like this would help me greatly. But if anyone knows of something much faster than this, I'm all ears

                If this feature ever gets implemented, having option(s) to have the pictures set on the bottom, side, or top would be good too for those who don't want a "centered" picture.
                Attached Files
                Last edited by nusakan; 12.08.2010, 11:44 PM.

                Comment


                  #9
                  Yes I understand what you have been doing, nusakan, and what I am suggesting is much quicker than that, because Irfanview is already doing what you want when it fits an image into a window. It just does not allow you to save the whole window. That is why you have to use screen capture instead.
                  Ignore the previous setting up instructions. I realize now that it is simpler to set up your "batch" list and capture from a slideshow. I have attached various dialogs and results to show what I did.

                  1. Opened Irfanview and set up the Fullscreen display option to Fit to window
                  2. Opened the Capture dialog and set up as shown. Click Start. The window minimizes to the Taskbar. Click on it there to open it up again.
                  3. Opened the Slideshow dialog and set up to display in a 960x800 window. Start the show.
                  4. Pressed Ctrl+F11 to capture the window. Spacebar to display next image.
                  5. Repeated step 4 for each image in the slideshow list. Just the 2 hotkey presses needed for each image in the list.
                  Attached Files

                  Comment


                    #10
                    Thanks for the reply Mij. This will work actually, though I was hoping to preserve the image size and just add the black spaces, but this is definitely much faster than what I'm doing by hand

                    Comment

                    Working...
                    X