Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Image sizing math problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Versions des environnements
Visual FoxPro:
VFP 9
Database:
MS SQL Server
Divers
Thread ID:
01076213
Message ID:
01076353
Vues:
20
David;

Well, we know we cannot resize it from 301 to 300 - that would create lousy results. So the routine would first have to decide when clipping is in order and when resizing is in order - and do whatever is best to get closest to 300x300.

So in this case we might expect some algorithm to balance the need for the two operations in some way (assuming clipping is available).

My thinking:
We need some way to determine the different even mathematical divisors for both width and height - we can divide by 2, 3, 5, 7, - any primes, in fact, that each side can be divided by evenly. We then need to decide which (if any) of those primes would get us closest to the target size, and then whether clipping (or enlarging the canvas size) would be in order.

If both sides are not divisible by the same prime to get close to 300, perhaps we need to trim one side first just to make it divisible by the same prime...

Hmmm... perhaps we need to take the long side, divide by the target size, look for the closest prim number... This is where I start to get dizzy.

>Michael,
>
>So what is an acceptable final size for your 602x602 image?
>
>In general I've found that you can almost always change an image by a factor of two a couple of times without serious degrading of the image.
>
>I don't know if GDI+ gives you any clipping functions or not, if it does you could clip the image from 0,0 to 599,599 and then resize it to 300x300.
>
>If not is resizing it from 602x602 to 301x301 and then down to 150x150 going to work?
>
>>I need to resize uploaded images to a max of 300x300.
>>
>>I can do a simple resize, but image quality is lousy depending upon the resizing proportions. For example, resizing 600x600 to 300x300 is great - but resizing 602x602 to 300x300 is lousy due to pixel averaging.
>>
>>So, when I do it manually in an image editor, I reduce it so that pixels are evenly divided using a calculator (and sometimes by adding whitespace around an image before reducing).
>>
>>I have to work out some mathematical method of doing this - does anyone have any insights before I start wrapping my brain around this problem?
Kogo Michael Hogan

"Pinky, are you pondering what I'm pondering?"
I think so Brain, but "Snowball for Windows"?

Ideate Web Site
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform