473,654 Members | 3,033 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

A good image scaling program?

Hello,
Can anyone recommend a good image scaling program for PHP 4. What
I'm really looking for is just a function that takes an image file and
a width to which to scale the image and outputs the scaled image.

I am grateful for anyone's recommendations , - Dave
Jul 17 '05 #1
4 5411
D. Alvarado wrote:
Hello,
Can anyone recommend a good image scaling program for PHP 4. What
I'm really looking for is just a function that takes an image file and
a width to which to scale the image and outputs the scaled image.

I am grateful for anyone's recommendations , - Dave


If you have imagemagick installed on the server that's an easy way to go.
There's also the GD library which may or may not be installed into PHP.

The GD functions are in the manual at http://www.php.net/gd

--
Chris Hope - The Electric Toolbox - http://www.electrictoolbox.com/
Jul 17 '05 #2
I noticed that Message-ID:
<9f************ **************@ posting.google. com> from D. Alvarado
contained the following:
Can anyone recommend a good image scaling program for PHP 4. What
I'm really looking for is just a function that takes an image file and
a width to which to scale the image and outputs the scaled image.

If you use the GD functions I'm not sure if there's a pre written
function that does it all.

First you get the dimensions of the uploaded image.
You need to derive the new image height by some simple maths

new height = (oldheight/oldwidth)*new width

Then use imagecopyresamp led to create the new image.

Lots of code examples about.
--
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs http://www.ckdog.co.uk/rfdmaker/
Jul 17 '05 #3
D. Alvarado wrote:
Hello,
Can anyone recommend a good image scaling program for PHP 4. What
I'm really looking for is just a function that takes an image file and
a width to which to scale the image and outputs the scaled image.

$src and $tgt are absolute paths to the source file and new image.
$size will be the maximum dimension (either width or height) of the
reuslting rescaled image.
If size isnt given, it will be 150 pixels.
function createthumb ($src,$tgt,$siz e=150) {
// create new thumbnail !
$src_img = imagecreatefrom jpeg($src);
if ($src_img) {
// calc portrait or landscape
if (imagesx($src_i mg) < imagesy($src_im g))
$scale = imagesy($src_im g) /$size;
else $scale = imagesx($src_im g) /$size;
// calc thumbnail dimensions
$new_w = round(imagesx($ src_img)/$scale);
$new_h = round(imagesy($ src_img)/$scale);
// create empty image of correct size & copy/resize image into it
$dst_img = imagecreatetrue color($new_w,$n ew_h);
imagecopyresize d($dst_img,$src _img,0,0,0,0,
$new_w,$new_h,
imagesx($src_im g),imagesy($src _img));
imagedestroy($s rc_img);
// save thumbnail to file
imagejpeg($dst_ img, $tgt);
imagedestroy($d st_img);
}
else print "<div class=error>fai led to open $src</div>";
}
Jul 17 '05 #4
"D. Alvarado" wrote:

Can anyone recommend a good image scaling program for PHP 4. What
I'm really looking for is just a function that takes an image file and
a width to which to scale the image and outputs the scaled image.


Try hotscripts.com. But that's also pretty easy to write (at least for JPG and
PNG) using the GD library.

Shawn
--
Shawn Wilson
sh***@glassgian t.com
http://www.glassgiant.com
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
3202
by: Phil Powell | last post by:
$mogResponse = exec("mogrify -size ${width}x$height " . $this->locationPath . '/' . $this->fileName . ' -resize ' . $width . "x$height > +profile " . $this->thumbLocationPath . '/' . $this->fileName .. ' 2>&1'); This attempt at creating a thumbnail only causes the original image to be resized while creating a "ghost image" in the /thumb folder where
3
8337
by: jeff | last post by:
Hiya, Im currently in the process of developing a picture browser, I want it to run off a CD, basically I have 2 questions for the group. The first is how do I get the program to only view the contents of the CD, at the moment i have a drop down drive menu that allows me to select the drive, i want to be able to put the CD in and then have i view only the CD contents, Ive considered just entering in my code D:\ but what happens if the...
11
18830
by: Jozef | last post by:
I have some old code that I use from the Access 95 Developers handbook. The code works very well, with the exception that it doesn't seem to recognize wide screens, and sizes tab controls so that they are too big and wind up covering up some of the fields on the main form. Is there any good code out there that works in a similar fashion that will also either a) stretch the form width wise on widescreens or b), rely on height rather than...
3
2549
by: Larry Serflaten | last post by:
I am taking a 256 color bitmap from a file and scaling it up X 16 to a 32bppPARGB bitmap in memory. I copy that image to the screen. After scaling, the edges of all the lines and colors are blurred. I want the edges all crisp, including inherent pixelation (jaggies). Setting smoothing to none, or adjusting the composting mode on the Graphics object still
3
2510
by: =?Utf-8?B?SlIx?= | last post by:
I would like to add text to an image. I have tried to use DrawString and it works on some images but on others it is very very small. I am pretty sure it has something to do with the size of the image but I have had varying results on multiple images. Is there anyway to make the text a fixed size on the image. Similar to putting a date on a photograph.
3
2526
by: Yofnik | last post by:
Hello all, I need your help. Internet Explorer 6+ has a registry setting (UseHR) that will automatically scale images for displays with high resolution (DPI). I am building a web based monitoring application that has some very detailed graphs and charts. I DO NOT want these images scaled under any circumstances. In fact, my graphs look better on high DPI screens when the are not scaled.
6
4801
by: Stephan Bourdon | last post by:
Hi, Your opinion please on the following subject: Is it acceptable to set the width and height of an image in ems or percents in CSS? The advantage for me is that images will scale up or down when the user changes the font size in the browser. But what of the disadvantages? In (X)HTML, the img-element will have a pixel-value for the width and height-attributes.
2
3068
by: Amir Michail | last post by:
Hi, The following gradient method involves scaling a gradient image. How would one put a logo on top of such a scaled gradient image without also scaling the logo image? http://www.alistapart.com/articles/supereasyblendys http://www.alistapart.com/d/supereasyblendys/examples/eg7.html Amir
4
2223
by: Peter May | last post by:
Hi. I know the dimensions area visible on the screen and I would like to picture that there put dynamically, match its size to the window, while retaining the proportions of course. For example: Screen area visible: 1280x589 The picture size: 3008x2000
0
8372
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8814
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8706
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8591
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7304
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6160
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5621
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1915
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.