473,396 Members | 1,982 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,396 software developers and data experts.

create and save an image

Hi all,

As a test to understand how to create and save a file on my server i
created the next code:
---

<html>
<head>
</head>
<body>

<?php

$thumb = imagecreatetruecolor(100, 100);
Imagejpeg($pic,"pic.jpg");
ImageDestroy($pic);

?>

<img src="pic.jpg">

</body>
</html>

---

Can anyone tell why the jpeg isn't saved and displayed. Can the
dir-settings be a cause?

Thanx,
WJ
Aug 14 '05 #1
5 10669
"Willem-Jan" <wj*******@home.nl> kirjoitti
viestissä:dd*********@news1.zwoll1.ov.home.nl...
Hi all,

As a test to understand how to create and save a file on my server i
created the next code:
---

<html>
<head>
</head>
<body>

<?php

$thumb = imagecreatetruecolor(100, 100);
Imagejpeg($pic,"pic.jpg");
ImageDestroy($pic);

?>


You create an image handler $thumb, but then as you call ImageJpeg, you are
using $pic. I wonder if it would help if you used $thumb all the time
instead of $pic (which would be an undefined variable at the time it's
called).

--
SETI @ Home - Donate your cpu's idle time to science.
Further reading at <http://setiweb.ssl.berkeley.edu/>
Kimmo Laine <et****************@5P4Mgmail.com>
Aug 14 '05 #2
That was a mistake the actual code is :

---
<html>
<head>
</head>
<body>

<?php

$pic = imagecreatetruecolor(100, 100);
Imagejpeg($pic,"pic.jpg");
ImageDestroy($pic);

?>

<img src="pic.jpg">

</body>
</html>
---

Same problem for that....

Kimmo Laine wrote:
"Willem-Jan" <wj*******@home.nl> kirjoitti
viestissä:dd*********@news1.zwoll1.ov.home.nl...
Hi all,

As a test to understand how to create and save a file on my server i
created the next code:
---

<html>
<head>
</head>
<body>

<?php

$thumb = imagecreatetruecolor(100, 100);
Imagejpeg($pic,"pic.jpg");
ImageDestroy($pic);

?>

You create an image handler $thumb, but then as you call ImageJpeg, you are
using $pic. I wonder if it would help if you used $thumb all the time
instead of $pic (which would be an undefined variable at the time it's
called).

Aug 14 '05 #3
>>>As a test to understand how to create and save a file on my server i
created the next code:


<html>
<head>
</head>
<body>

<?php

$pic = imagecreatetruecolor(100, 100);
Imagejpeg($pic,"pic.jpg");
ImageDestroy($pic);

?>

<img src="pic.jpg">

</body>
</html>


I ran this code in my development environment and it worked. I got a page
with a black square 100x100. The image pic.jpg was also saved in the same
directory as the script.

Perhaps your script does not have permission to write the file in that
directory?
Perhaps you don't actually have the GD Library installed? check phpinfo()
for the GD Section - if it isn't there, it isn't installed.
Try this php script: with no HTML

<?php
ini_set( 'display_errors', '1' );
error_reporting (E_ALL ^ E_NOTICE);
function my_error_handler ($errno, $errstr, $errfile, $errline) {
echo "In $errfile, line: $errline\n - $errstr<br>";
}
set_error_handler ('my_error_handler');

$pic = imagecreatetruecolor(100, 100);
Imagejpeg($pic);
ImageDestroy($pic);

?>

That *should* display errors to the browser if you have any, and they may
let you know why thintgs aren't working.

Michael
Aug 14 '05 #4
JDS
On Mon, 15 Aug 2005 09:49:26 +1000, Michael Phipps wrote:
Perhaps your script does not have permission to write the file in that
directory?


Almost certainly it is a directory permissions problem. Is this a Unix
(Linux, BSD, wahtever) host? Remember that the web server normally runs
under a non-priveleged user, such as "nobody" or "webuser" or somesuch,
and this user has rather limited write capabilities. Try adding world
writeableness to the current directory:

chmod 777 .

later...

--
JDS | je*****@go.away.com
| http://www.newtnotes.com
DJMBS | http://newtnotes.com/doctor-jeff-master-brainsurgeon/

Aug 15 '05 #5
Changing the permissions solved the problem.

Thanx!

JDS wrote:
On Mon, 15 Aug 2005 09:49:26 +1000, Michael Phipps wrote:

Perhaps your script does not have permission to write the file in that
directory?

Almost certainly it is a directory permissions problem. Is this a Unix
(Linux, BSD, wahtever) host? Remember that the web server normally runs
under a non-priveleged user, such as "nobody" or "webuser" or somesuch,
and this user has rather limited write capabilities. Try adding world
writeableness to the current directory:

chmod 777 .

later...

Aug 15 '05 #6

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

Similar topics

2
by: Programmer | last post by:
Hi all Here is my problem I want to create an image so i can pass it on an object to put it as watermark in my pdf report Here is what i have write so far Dim objBitmap As...
3
by: James Dean | last post by:
I have read that you can create a 1bpp png image but has anyone any idea how to do it?...... *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in...
2
by: Mango | last post by:
Hi there, I will be very happy if someone helps me. I need to create dynamic image, and save the state between the postback. I mean I've got 5 buttons and when I click on one of them, the image is...
7
by: John Williams | last post by:
Does anyone know a way of creating a PNG file containing several GIF files programmatically (using Visual Basic)? Here's what I do manually in Fireworks. Each Gif is 200 x 200 pixels. 1....
8
by: barb | last post by:
So that the world at large benefits from our efforts, here is one fully documented way to use Windows Irfanview freeware to create thumbnail web galleries (http://www.irfanview.com). STEP 1:...
1
by: miguelfc | last post by:
Hi, I've searched a lot and couldn't find an answer to my problem. I want to have a field in my form that allow me to paste an image from the clipboard to, for example, a Paint field. Then, I...
3
by: pedrito | last post by:
I've got an app that downloads images off the internet using anywhere from 1-20 threads concurrently (though generally around 4 threads). I have a preview page that shows the images as they're...
0
by: Dale | last post by:
Access 2000 I have a check scanner from Magtek, (MicrImage) This is like a "point of sale" check scanner/credit card reader. Magtek furnished 2 ocx's (MTMicrImage.ocx & SaxComm8.ocx). They also...
11
by: Mark B | last post by:
I want to display a pre-designed graphical 'performance badge' on certain webpages (round, about 2cm diameter) next to a salesperson's details. I have a function,...
12
by: Bob Bedford | last post by:
I've to build a website where the customer can buy an image. I'm thinking in the 2 ways to let people get those images: receive them by Email or send them an image link wich validity is limited in...
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?
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
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
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,...
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
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.