Image Resizing Script required - a better one...

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

User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

You could pass an empty array to options, or you could specify compression level 9 (which is the highest). How specifically you implement that is up to you and would depend somewhat on your use case. You say "when an image is 2560". When it's exactly that wide? When it's that wide or larger? When you're processing an image for a screen width of 2560?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

The problem we are facing, is when certain banners are uploading, with let's say an orange block and some text it in, it gets compressed a bit (we altered it to 95), and the quality is reduced not brilliantly.
But we tried the same banner in Wordpress and it didn't lose that quality.

I thought the 4K versions weren't compressed but they obviously are. On the 1920 versions people are seeing the reduction in quality. I don't know why. Slight blurring on text for example.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

Well to begin with you probably don't want to be using JPG + text, but that's maybe a separate issue. What are you starting with, what are you resizing to, and what are you ending up with?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

simonmlewis wrote:But we tried the same banner in Wordpress and it didn't lose that quality.
Have you looked at how they do it?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

I wouldn't know where to start to look.
Clearly their code is slightly different. I just did another, as we added that code to another page - quality isn't so sharp. Even at 95%!
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: Image Resizing Script required - a better one...

Post by Celauran »

You're resizing from the same original image to the same sizes? Quality of all the test images I did was fine, but none had text. Any way you can be more specific? Anything you can show us for the sake of comparison?
simonmlewis
DevNet Master
Posts: 4435
Joined: Wed Oct 08, 2008 3:39 pm
Location: United Kingdom
Contact:

Re: Image Resizing Script required - a better one...

Post by simonmlewis »

Hi. I am usinig this function code now for a slightly different purpose, and need to pass thru to the directory structure, a variable, to dynamically change what folder the image is being saved into.

It's part of a different thread, but as this thread is the core code I am using, wanted to add it here.
Love PHP. Love CSS. Love learning new tricks too.
All the best from the United Kingdom.
Post Reply