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

New Image File

Consider the following code:

<?php

$image = imagecreatefromjpeg($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresampled($image_p, $image, 0, 0, 0, 0, 200,
$height*$ratio, $width, $height);

?>

How do I save $newimage as "images/image.jpg"?

Oct 28 '05 #1
7 1834
>Consider the following code:

<?php

$image = imagecreatefromjpeg($_FILES['imagefile']['tmp_name']);
$newimage = imagecopyresampled($image_p, $image, 0, 0, 0, 0, 200,
$height*$ratio, $width, $height);

?>

How do I save $newimage as "images/image.jpg"?


imagejpeg($newimage, 'images/image.jpg');

Oct 28 '05 #2
Thank you very much, that worked splendidly. Now I have one more
question. I'm performing a similar task with a GIF file, but PHP tells
me imagegif() doesn't exist. Why would that be? I'm running PHP 4.3.2.

Oct 28 '05 #3
On Fri, 28 Oct 2005 05:33:20 +0300, Trevor <tr*********@gmail.com> wrote:
Thank you very much, that worked splendidly. Now I have one more
question. I'm performing a similar task with a GIF file, but PHP tells
me imagegif() doesn't exist. Why would that be? I'm running PHP 4.3.2.


Looks like yuo're saying about Win32 version of GD...
If so - it really doesnt work. But on .nix platforms it does (sure if the
newest GD module installed)
--
Exact Meta Search
http://exactsearcher.com
Oct 28 '05 #4
question. I'm performing a similar task with a GIF file, but PHP tells
me imagegif() doesn't exist. Why would that be? I'm running PHP 4.3.2.


First check the output from phpinfo(); to see what is compiled
in/available. What you do next depends on your OS. See
<http://www.php.net/manual/en/ref.image.php> for details.

---
Steve

Oct 28 '05 #5
Trevor wrote:
PHP tells me imagegif() doesn't exist.


Use imagepng() instead.

--
E. Dronkert
Oct 28 '05 #6
I'm running Red Hat. phpinfo() tells me this:

GD Support enabled
GD Version bundled (2.0.12 compatible)
FreeType Support enabled
FreeType Linkage with freetype
GIF Read Support enabled
JPG Support enabled
PNG Support enabled
WBMP Support enabled
XBM Support enabled

Oct 29 '05 #7
GD Support enabled
GD Version bundled (2.0.12 compatible) From the reference quoted above:


"The format of images you are able to manipulate depend on the version
of GD you install, and any other libraries GD might need to access
those image formats. Versions of GD older than gd-1.6 support GIF
format images, and do not support PNG, where versions greater than
gd-1.6 and less than gd-2.0.28 support PNG, not GIF. GIF support was
re-enabled in gd-2.0.28."

You need to upgrade your GD.

---
Steve

Oct 29 '05 #8

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

Similar topics

3
by: dave | last post by:
Hello there, I am at my wit's end ! I have used the following script succesfully to upload an image to my web space. But what I really want to be able to do is to update an existing record in a...
11
by: bissatch | last post by:
Hi, I am trying to upload an image, create a new file based on that image and then store the base64 encoded image data in a database. I dont really know where my code is going wrong so I will...
15
by: Anand Ganesh | last post by:
HI All, I have an Image. I want to clip a portion of it and copy to another image. How to do this? I know the bounding rectangle to clip. Any suggestions please. Thanks for your time and...
0
by: Duncan Welch | last post by:
I've got users uploading a file, which I then want resize, make a thumbnail out of, then delete. The image and thumbnail are working fine, but when I try to delete the image, I get an error: "The...
0
by: Satish Appasani | last post by:
Hi: I have a ASP.NET form with Web layout which I've achieved using panels. In one of the tab I have a File control to upload Images. When I put a file in the file control and move to another...
7
by: Scott Schluer | last post by:
Is there a way to use the Image class to convert a color photo (GIF or JPEG) to a B&W photo? Thanks, Scott
6
by: Patrick Dugan | last post by:
Hello, I'm trying to load different images (icons) into a PictureBox1.Image. The first image loads just fine, but the second image always returns the error "Invalid property used." It doesn't...
7
by: lgbjr | last post by:
Hello All, I¡¯m using a context menu associated with some pictureboxes to provide copy/paste functionality. Copying the image to the clipboard was easy. But pasting an image from the clipboard...
1
by: bharathv6 | last post by:
i need to do is modify the image in memory like resizing the image in memory etc ... with out saving it disk as i have to return back the image with out saving it disk PIL supports the use of...
0
Debadatta Mishra
by: Debadatta Mishra | last post by:
Introduction In this article I will provide you an approach to manipulate an image file. This article gives you an insight into some tricks in java so that you can conceal sensitive information...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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...

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.