Round print sizes (inches) from width & height in pixels

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Round print sizes (inches) from width & height in pixels

Post by Skara »

Ok, maybe this is a bit confusing... I can't figure out how to go about this.

Say I have an array of image sizes:

Code: Select all

$sizes = array(
        array(2048,1536),
        array(1280,768),
        array(3008,2000),
        array(2764,1396),
        array(1301,1992),
        array(4296,2608),
        array(4461,4106),
        );
Now I want to figure out a few different sizes that would be printable. For example...

3008x2000 would fit into a 4x6, 8x12, and so on. Up to a 16x24.
4461x4106 wouldn't fit into any thing real well. A 5x5 would work, though. It would end up being 5x4.6, but that's close enough.

Valid sizes are..
4x5,4x6,5x5,5x7,8x8,8x10,8x12,10x10,11x14,10x15,12x12,12x18,16x16,16x20,16x24
Off the top of my head. Might have missed some.

So, in a nutshell:
I need to figure out what sizes are valid for the image dimensions and record it and the actual dimensions it would be. (Ex: 1992x1301 would be 8x12 and 12.249x8)

I really don't know where to start, any help would be appreciated.
User avatar
andym01480
Forum Contributor
Posts: 390
Joined: Wed Apr 19, 2006 5:01 pm

Post by andym01480 »

It all depends on the DPI of your printer. eg. 600DPI printer prints 600pixels per inch etc. That's what affects the phyical size of prints on paper.

So you would need that as a variable, then it is a matter of calculating etc.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

err.... no.
I can print a 4000x6000 image as a 4x6, 8x12, 10x15, etc regardless of the dpi, but I can't print it as a 5x5.

I want to figure out what proportions the image fits.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

so you can calculate the ratio of your image and compare it to the ratio of destination formats... for 4000x6000 it would be 1.5 but for 5x5 it's 1.
User avatar
Skara
Forum Regular
Posts: 703
Joined: Sat Mar 12, 2005 7:13 pm
Location: US

Post by Skara »

hm. Well, I guess the solution was staring me right in the face. ^^;

Thanks.
Post Reply