Scaling down png image using GD library in PHP

Posted on 2005-03-15
Medium Priority
Last Modified: 2012-08-14

I am using PHP and GD library to create png images on the fly.  Most of the time, these images are too large to fit into a A4 size print page. Is there any way to resize these images once the png file is created?


Question by:lword
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 33

Accepted Solution

snoyes_jw earned 500 total points
ID: 13545402
LVL 25

Assisted Solution

by:Marcus Bointon
Marcus Bointon earned 500 total points
ID: 13545888
You can scale the image down using the above functions, but it will degrade output quality, especially for print.

The print size is independent of the pixel size. Most image formats allow you to specify a real world resolution (though Windows tends to ignore it), or you can simply assign an image a size in real-world dimensions (like mm or inches) in your print-specific stylesheet (You do have one of those right? ;^)) so that it comes out exactly the size you want, without having to rescale or lose quality. Read these articles for info on print formatting with CSS:


If the image is just plain, not embedded in a page, you can't go this route, and you will have to rescale.
LVL 14

Expert Comment

ID: 15862075
No comment has been added to this question in more than 21 days, so it is now classified as abandoned..
I will leave the following recommendation for this question in the Cleanup topic area:
Split the points between snoyes_jw and Squinky.

Any objections should be posted here in the next 4 days. After that time, the question will be closed.

EE Cleanup Volunteer

Featured Post

WordPress Tutorial 2: Terminology

An important part of learning any new piece of software is understanding the terminology it uses. Thankfully WordPress uses fairly simple names for everything that make it easy to start using the software.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question