Results 1 to 10 of 10

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

  1. #1
    IV Newbie
    Join Date
    May 2010
    Posts
    2

    Default 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. #2
    Moderator Sam_Zen's Avatar
    Join Date
    May 2007
    Location
    NL
    Posts
    1,896
    Version
    IrfanView 4.27
    OS
    Win XP Home SP1
    CPU Cores
    1

    Default

    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!

  3. #3
    IV Newbie
    Join Date
    May 2010
    Posts
    2

    Default

    Quote 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

    http://www.xs4all.nl/~samzen/downloa...iv_options.txt

  4. #4
    Advanced User matera's Avatar
    Join Date
    May 2006
    Location
    3 miles below poverty level
    Posts
    1,384
    Version
    IrfanView 4.44
    OS
    64-bit Linux Distribution
    CPU Cores
    4

    Default

    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

  5. #5
    Moderator Sam_Zen's Avatar
    Join Date
    May 2007
    Location
    NL
    Posts
    1,896
    Version
    IrfanView 4.27
    OS
    Win XP Home SP1
    CPU Cores
    1

    Default

    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!

  6. #6
    IV Newbie
    Join Date
    Aug 2010
    Posts
    6
    Version
    IrfanView 4.27
    OS
    64-bit Win 7
    CPU Cores
    4

    Default

    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.

  7. #7
    Professional User Mij's Avatar
    Join Date
    Mar 2007
    Location
    Camberley, Surrey, UK
    Posts
    2,764
    Version
    IrfanView 4.51
    OS
    32-bit Win 10
    CPU Cores
    3

    Default

    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.

  8. #8
    IV Newbie
    Join Date
    Aug 2010
    Posts
    6
    Version
    IrfanView 4.27
    OS
    64-bit Win 7
    CPU Cores
    4

    Default

    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 Thumbnails Attached Thumbnails Click image for larger version. 

Name:	Group-Picture-686.jpg 
Views:	282 
Size:	298.9 KB 
ID:	2326   Click image for larger version. 

Name:	Group-Picture-686-new.jpg 
Views:	271 
Size:	333.3 KB 
ID:	2327  
    Last edited by nusakan; 12.08.2010 at 10:44 PM.

  9. #9
    Professional User Mij's Avatar
    Join Date
    Mar 2007
    Location
    Camberley, Surrey, UK
    Posts
    2,764
    Version
    IrfanView 4.51
    OS
    32-bit Win 10
    CPU Cores
    3

    Default

    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 Thumbnails Attached Thumbnails Click image for larger version. 

Name:	fullscreen dialog.jpg 
Views:	516 
Size:	68.6 KB 
ID:	2330   Click image for larger version. 

Name:	capture dialog.jpg 
Views:	375 
Size:	46.9 KB 
ID:	2331   Click image for larger version. 

Name:	slideshow dialog.jpg 
Views:	386 
Size:	103.8 KB 
ID:	2332   Click image for larger version. 

Name:	capture_13082010_195632.jpg 
Views:	284 
Size:	110.8 KB 
ID:	2333   Click image for larger version. 

Name:	capture_13082010_195634.jpg 
Views:	270 
Size:	122.1 KB 
ID:	2335  


  10. #10
    IV Newbie
    Join Date
    Aug 2010
    Posts
    6
    Version
    IrfanView 4.27
    OS
    64-bit Win 7
    CPU Cores
    4

    Default

    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

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •