473,799 Members | 3,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 = imagecreatetrue color(100, 100);
Imagejpeg($pic, "pic.jpg");
ImageDestroy($p ic);

?>

<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 10695
"Willem-Jan" <wj*******@home .nl> kirjoitti
viestissä:dd*** ******@news1.zw oll1.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 = imagecreatetrue color(100, 100);
Imagejpeg($pic, "pic.jpg");
ImageDestroy($p ic);

?>


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.ber keley.edu/>
Kimmo Laine <et************ ****@5P4Mgmail. com>
Aug 14 '05 #2
That was a mistake the actual code is :

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

<?php

$pic = imagecreatetrue color(100, 100);
Imagejpeg($pic, "pic.jpg");
ImageDestroy($p ic);

?>

<img src="pic.jpg">

</body>
</html>
---

Same problem for that....

Kimmo Laine wrote:
"Willem-Jan" <wj*******@home .nl> kirjoitti
viestissä:dd*** ******@news1.zw oll1.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 = imagecreatetrue color(100, 100);
Imagejpeg($pi c,"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 = imagecreatetrue color(100, 100);
Imagejpeg($pic, "pic.jpg");
ImageDestroy($p ic);

?>

<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_handle r ($errno, $errstr, $errfile, $errline) {
echo "In $errfile, line: $errline\n - $errstr<br>";
}
set_error_handl er ('my_error_hand ler');

$pic = imagecreatetrue color(100, 100);
Imagejpeg($pic) ;
ImageDestroy($p ic);

?>

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
3124
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 System.Drawing.Bitmap
3
5224
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 USENET...get rewarded for it!
2
2287
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 creted with: System.Web.UI.WebControls.Image Img1 = new System.Web.UI.WebControls.Image(); Img1.ImageUrl = newPath; Panel1.Controls.Add(Img1);
7
2833
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. Create a new canvas, 400 x 400. 2. Import Gif 1 and position in top left corner (x=0, y=0) 3. Import Gif 2 and position in bottom left corner (x=0, y=200) 4. Import Gif 3 and position in top right corner (x=200, y=0) 5. Import Gif 4 and position in...
8
20371
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: Start with original thumbnails & two empty sub directories STEP 2: Create smaller versions of the originals for one sub directory STEP 3: Create thumbnail version of the originals the other sub directory STEP 4: Create an index.html pointing to the...
1
4093
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 want to save that image to a file on a specific folder in my computer via VB. The reason for this is that I don't want to ask the user to open paint by himself and save the file, probably in the wrong location and with the wrong name. The first...
3
4661
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 downloading. The threads that do the downloading trigger an event every 32K (the size of the chunks I receive), at which point the images are drawn in the Preview page. To create the images, I create a memory stream from the data and then use...
0
1449
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 give example VB code. I need to make this work in Access. I know the following code will require a lot of modification for VBA. My Problem is getting started - I have copied the ocx's to the
11
5392
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, fGetPerformanceGrade(SalesPersonID as Long) as String to retrieve that salesperson's grade (e.g. A+, A, A-, B+, B... D). Also one other function, fGetMonthlySales(SalesPersonID as Long) as String to get their sales figure, e.g. "$87K". I want web visitors to be able to click...
12
4022
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 time. The second may help me to know if an image has been downloaded and how many times. How to build such download link ? The informations I'd like is the userid, the datetime limit and the imagefile, off course everything must be encrypted...
0
9687
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9543
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10237
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10029
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9077
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7567
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5588
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4144
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2941
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.