473,407 Members | 2,315 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,407 software developers and data experts.

resizing an image with the gd library

I'm trying to resize an image with the gd library and am having some
difficulty. Here's my code:

<?php

$img = 'http://upload.wikimedia.org/wikipedia/commons/e/e3/Kheops-
Pyramid.jpg';
list($width, $height) = getimagesize($img);
$img = imagecreatefromjpeg($img);

$temp = imagecreate(500, 500);
imagecopyresized($img, $temp, 0, 0, 0, 0, 500, 500, $width, $height);

header('Content-type: image/jpeg');
imagejpeg($temp);
?>

All I get is a 500x500 black picture. What I don't get is a resized
wikimedia.org picture. Any ideas as to what I'm doing wrong?
Nov 20 '07 #1
1 1623
On Nov 19, 8:06 pm, ljb <lba...@pobox.com.nospamwrote:
terra1...@yahoo.com wrote:
I'm trying to resize an image with the gd library and am having some
difficulty. Here's my code:
<?php
$img = 'http://upload.wikimedia.org/wikipedia/commons/e/e3/Kheops-
Pyramid.jpg';
list($width, $height) = getimagesize($img);
$img = imagecreatefromjpeg($img);
$temp = imagecreate(500, 500);
imagecopyresized($img, $temp, 0, 0, 0, 0, 500, 500, $width, $height);
header('Content-type: image/jpeg');
imagejpeg($temp);
?>
All I get is a 500x500 black picture. What I don't get is a resized
wikimedia.org picture. Any ideas as to what I'm doing wrong?

Check usage on imagecopyresized. I think you switched source and
destination, i.e. you copied your fresh blank image over onto the pyramid
image.
That was it - thanks!
Nov 20 '07 #2

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

Similar topics

2
by: Alex Hopson | last post by:
I'm using the code below to loop through some images and resize each image twice, once to create a thumbnail and once to create a small image. The page stops loading around the 38th image out of...
2
by: Clyde Ellul | last post by:
Hi there. I need to write a simple program that reads a GIF image from an input stream, resizes it, then writes it back to an output stream in the same format (GIF). (JPEG input/output is good...
1
by: Ron Vecchi | last post by:
I am using asp.net to upload an image and then perform resizing on it and saving the different sizes to file. The resized images were coming up and being displayed in the bowser fine but the image...
3
by: Koen Hoorelbeke | last post by:
Hi there, I want to read a jpg-file from a url (f.e. http://someserverWhichIsNOTLocal/images/test.jpg), get the dimensions, resize it, save it to my local disk on the webserver as a gif-image and...
6
by: neverstill | last post by:
hi- So I wrote this nice little page that will allow the managers to add images to the products table. Without too many details to confuse everything, basically what I'm doing is: getting an...
10
by: David W. Simmonds | last post by:
I have a DataList control that has an Image control in the ItemTemplate. I would like to resize the image that goes into that control. I have a series of jpg files that are full size, full...
5
by: Tuvas | last post by:
I am seeking a way to resize a PIL image, even if the original is a smaller dimention than the new size. Resizing seems to only make an image smaller, and not larger. I have a 700x700 sized...
6
by: tomasio | last post by:
Dear NG, years have passed and I am still more designer than programmer. I build a new version of my website which has a few nasty bugs, especially on my startpage: Resizing text brakes the...
10
by: mishrarajesh44 | last post by:
hii all, I am facing a problem currently.. i have a script for image uploading and resizing.. the image uploading takes place properly for every size images.. but, the resizing works for...
8
by: brahmaforces | last post by:
Hi Folks, I am using cherrypy and python. I am trying to get a user profile image to resize on the client side before uploading to the server. PHP has a gd library that does it it seems. Has...
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: 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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
0
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,...

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.