aspect-ratio-based canvas resize

Ideas for improvements and requests for new features in XnView Classic

Moderators: helmut, XnTriq, xnview

Post Reply
blah789
Posts: 12
Joined: Wed Oct 03, 2012 3:31 am

aspect-ratio-based canvas resize

Post by blah789 »

problem: when you go to a photo lab to have your digital pictures printed, if the aspect ratio doesn't match that of the print size, the image gets cropped automatically. it doesn't matter if you request to have borders added. it adds borders on all 4 sides with the same cropping (meaning the picture's just smaller as unbordered, but with four white borders around).
what we want is the image unmodified, even if it means adding only two white borders (either on top+bottom, or left+right)

menu:
enter print size or ratio (4x6 5x7 or 4:6 5:7 2:3) or as a decimal (1.3333 1.4 1.5)
border color
keep pixel parity checkbox (so that say you have 1500 pixels and it computes to 1801 pixels, you resize it to 1802 pixels so that you don't need to do ½ pixel interpolation)

optional: smart orientation (so it knows which side is the "long" side before making the adjustment - I'll elaborate)
optional: position (9 positions like in regular canvas resize)

algorithm idea:
(simple example)
say your digicam took a 1600x1200 pic, and the print size you want is 4x6
so ratio is 6/4 = 1.5
do a test:
short side x 1.5 = 1200 x 1.5 = 1800 (potential new long side)
check
1800 > old long side
1800 > 1600
OK (no chopping off of image)
check parity
(1800 - 1600) mod(2) = 0
no need to add extra pixel (if it had been 1, you'd add an extra pixel)
perform canvas resize with other chosen parameters (image becomes 1800x1200, with 100 pixels borders on both sides)

(example 2)
say your scan is 7000x3000 and you want a print size of 5x7
ratio is 7/5 = 1.4
do a test
3000 x 1.4 = 4200 (potential new short side)
check: is 4200 > 7000?
NO. so to avoid cropping, we go the other way
7000/1.4 = 5000 (potential new long side)
check is 5000 > 3000
yes, so new size is 7000x5000
and we do canvas resize with those dimensions (1000 pixels borders on right and left)

I espect a few hics when dealing with special cases like 1:1 ratios (some shops offer 4x4 5x5 and 6x6 prints)

-----------------------------------------------------------------------------

the alternative is to allow the regular canvas resize to change one side as a percentage of the other side
new_width = old_width
new_height = old_width x 1.5
(which gives a final aspect ratio of 1.5)



topic discussed in this thread
http://newsgroup.xnview.com/viewtopic.php?f=35&t=26889
blah789
Posts: 12
Joined: Wed Oct 03, 2012 3:31 am

Re: aspect-ratio-based canvas resize

Post by blah789 »

I was pondering over that smart orientation feature.

(see illustration)
say you have the 900x100 pic and you want a 4x6 print (aspect ratio 1.5)

I was thinking you could do
900/1.5 = 600
so 900x600 (aspect ratio 1.5)

or you could go
900 x 1.5 = 1350
and 900 x 1350 (still aspect ratio 1.5!)

however you always divide, right? (or do you?) haven't thought this out completely.
or do you determine the "short side" first?
Attachments
incorrect resizing
incorrect resizing
example.jpg (22.14 KiB) Viewed 1966 times
blah789
Posts: 12
Joined: Wed Oct 03, 2012 3:31 am

Re: aspect-ratio-based canvas resize

Post by blah789 »

like I said, I think the hics will be with square or near-square pictures.
how do you decide which way to resize? (assuming print size is non-square)
say a bunch of scans come out
500x500
498x503
504x499
etc...

you could have a setting force add border left+right or top+bottom if 1 < aspect ratio of pic < aspect ratio of print ? (we presume aspect ratio is larger number divided by smaller number)
in which case you pretty much assume the user has all their scans correctly oriented.
User avatar
JohnFredC
XnThusiast
Posts: 2010
Joined: Wed Mar 17, 2004 8:33 pm
Location: Sarasota Florida

Re: aspect-ratio-based canvas resize

Post by JohnFredC »

If you think about it, wouldn't it always be preferable to oversample?

For instance:
I was thinking you could do
900/1.5 = 600
so 900x600 (aspect ratio 1.5)

or you could go
900 x 1.5 = 1350
and 900 x 1350 (still aspect ratio 1.5!)
If I understand you, the 2nd option would better preserve the image quality.
John
blah789
Posts: 12
Joined: Wed Oct 03, 2012 3:31 am

Re: aspect-ratio-based canvas resize

Post by blah789 »

JohnFredC wrote:If you think about it, wouldn't it always be preferable to oversample?

For instance:
I was thinking you could do
900/1.5 = 600
so 900x600 (aspect ratio 1.5)

or you could go
900 x 1.5 = 1350
and 900 x 1350 (still aspect ratio 1.5!)
If I understand you, the 2nd option would better preserve the image quality.
no, because you're just adding borders. look at the pic. the borders are just longer. the pic would turn out tiny while the borders would be huge.
Post Reply