473,222 Members | 1,815 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,222 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 10658
"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...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...

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.