473,385 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

resized images give crappy quality - why?

The script below resizes images into two different sizes. My problem is that
the quality of the resized images is poor. Any idea how to improve my
script? The users are only uploading jpg's.

Thanks!
Dag Eilertsen
__________________________________________________ __________________________
_

$bilde = "./" .$lagringssti .$filnavn1;
$pic = @imagecreatefromjpeg($bilde) or die("Sorry!");
if ($pic)
{
// Make thumb
$width = imagesx($pic);
$height = imagesy($pic);
$twidth = 100;
$theight = $twidth * $height / $width; // Regner ut høyden

$thumb = @imagecreatetruecolor ($twidth, $theight) or die ("Can't
resize!");
imagecopyresized($thumb, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height); // Resize to thumb
imagegammacorrect($thumb, 1.0, 1.5);

ImageJPEG($thumb,$lagringssti .basename($filnavn1,'.jpg')
.."_thmb.jpg",100); // JPEG of thumb

// Make small image
$twidth = 230; // Vidde satt til 230 pixler
$theight = $twidth * $height / $width; // Regner ut høyden
$mediumPic = @imagecreatetruecolor ($twidth, $theight) or die ("Can't
change size");
imagecopyresized($mediumPic, $pic, 0, 0, 0, 0, $twidth, $theight, $width,
$height);

imageJPEG($mediumPic,$lagringssti .basename($filnavn1,'.jpg')
.."_small.jpg",100);

imagedestroy($thumb);
imagedestroy($mediumPic);

// Delete the original file
list($stamme, $extension) = split("\.", $filnavn1);

unlink($lagringssti .basename($filnavn1));

} // End: if ($pic)
Jul 17 '05 #1
3 1468
I noticed that Message-ID: <40******@news.broadpark.no> from Dag
Eilertsen contained the following:
The script below resizes images into two different sizes. My problem is that
the quality of the resized images is poor. Any idea how to improve my
script?


Use imagecopyresampled()
--
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 #2
Use ImageMagick, not GD

"Geoff Berrow" <bl******@ckdog.co.uk> wrote in message
news:0i********************************@4ax.com...
I noticed that Message-ID: <40******@news.broadpark.no> from Dag
Eilertsen contained the following:
The script below resizes images into two different sizes. My problem is thatthe quality of the resized images is poor. Any idea how to improve my
script?


Use imagecopyresampled()
--
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
I noticed that Message-ID:
<2W********************@news20.bellglobal.com> from Alex contained the
following:
Use ImageMagick, not GD


Users don't always have a choice.

--
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 #4

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

Similar topics

4
by: jn | last post by:
I'm working with images from a Kodak 2MP camera. It looks like the function will only create a resource if I give it horiznotal pictures from this camera....if I give it vertical (height larger...
6
by: Robert J. O'Hara | last post by:
I'm one of those people who practices what some consider "dull" and others consider "elegantly conservative" page design. I appreciate good traditional typography and standards-compliant liquid...
7
by: Vinay | last post by:
Hi All: I have a small application that stores images either in the database or as files (depending on the user preference). I'm in the process of providing a web interface to this application....
4
by: Dom Hicklin | last post by:
I have created a form onto which images can be dropped and thus added to the OLE field of a Table (Access 2000 linked to SQL 2000 server). I use the Stephen Lebans ExportOLE function to do this...
3
by: Bob Dydd | last post by:
Hi Everybody I have an Access 2000 db with a setup for inserting images in records. I am using the image path only with the actual images stored elswhere on the hard disc. This works perfectly...
1
by: toma | last post by:
Hi! I found out how to manipulate (read,resize, etc..) images using System.Drawin namespace from this site: http://authors.aspalliance.com/chrisg/default.asp?category=9 But i don't know how to...
6
by: Neo Geshel | last post by:
Greetings. I am making an admin interface, which allows me to upload photos to an access DB. The admin interface also needs to display the uploaded photos, but only needs to show them at a...
6
by: NutsAboutVB | last post by:
Hello, I am a .NET programmer and I have a JPEG image file (from digital camera) of about 109 KB's in size, when I open it and save it (without making any alterations at all, just going to File...
4
by: Anna97 | last post by:
Hi, I guess I've built my site sort of strangely: The images are in the html (using tables), but the text is all in css positioned using coordinates (hovering over the images). I need my page...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.