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

resize an image

Hi does anybody know's what's wrong with the following code :

if (($imgsize[0] > 250) || ($imgsize[1] > 200)) {
$tmpimg = tempnam("/avatard", "MKUP");
system("djpeg $file >$tmpimg");
system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$file");
copy($file, "avatard/" . $nom_utilisateur.".jpeg");
unlink($tmpimg);
}

image 're not resized :(

thanks in advance

Jul 17 '05 #1
1 2592
Alexandre Jaquet wrote:
Hi does anybody know's what's wrong with the following code :
This code lacks a lot of error checking
if (($imgsize[0] > 250) || ($imgsize[1] > 200)) {
$tmpimg = tempnam("/avatard", "MKUP");
if ($tmpimg === false) die('Cannot create temporary filename.');
## system("djpeg $file >$tmpimg");
system("djpeg $file >$tmpimg", $status_code);
/* assuming a status code of 1 or greater is an error */
if ($status_code > 1) die('Error executing djpeg.');

system("pnmscale -xy 250 200 $tmpimg | cjpeg -smoo 10 -qual 50 >$file");
## copy($file, "avatard/" . $nom_utilisateur.".jpeg");
if (!copy($file, "avatard/" . $nom_utilisateur.".jpeg")) {
/* probably an error */
}
## unlink($tmpimg);
if (!unlink($tmpimg)) {
/* unable to delete the file */
/* die() or do something else */
}
} image 're not resized :(


As for the system calls (djpeg and pnmscale) I have no idea if they're
wrong or right, if they worked or not ... and neither have you :-)

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #2

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

Similar topics

3
by: Z D | last post by:
Hello, BACKGROUND: ============== I've created a Windows User Control that contains an Image Control (among other controls). The user control handles the picture resize event. Whenever the...
14
by: Rudy | last post by:
Hello all! I been trying to get a handle with Images. I have learned alot from the fine people here. So, I also learned that thumbnail images look terrible taken from a digital cam. I know why...
2
by: Carl Gilbert | last post by:
Hi I am looking for either a component or technique to allow me to do the following: * Provide a panel with a background image * Resize the image to best fit the panel to maintain aspect...
15
by: David Lozzi | last post by:
Howdy, I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders! Now I am making a public function that will take the...
1
by: Arjen | last post by:
Hi, I want to resize an image on my server. I tried a lot of samples... but all the time it does resize and saves the images but I can not view the image insize a webbrowser. With an...
2
by: Tim Arnold | last post by:
Hi, I'm using the Image module to resize PNG images from 300 to 100dpi for use in HTML pages, but I'm losing some vertical and horizontal lines in the images (usually images of x-y plots). ...
2
by: Dominic Vella | last post by:
Hi, I know I seem to have the really complicated questions, but I guess that's why I'm here. This is a little verbose, only because I've been trying to crack this for a week now. Your help...
8
by: infoseekar | last post by:
Image Resize & Rotation Hi I have 2 scripts, one for Image rotation and other image resize and they both are working. Image resize scripts load the picture and resize it and Image rotation...
3
by: =?Utf-8?B?UiBSZXllcw==?= | last post by:
Hi! This discussion may help other programmers get a better idea of how to save uploaded images through a website. Why? Well currently, I save 3 versions of every uploaded image on my own...
22
by: simon2x1 | last post by:
i have an image which width is 213 and height is 200 when i echo the image and i resize it echo "<img src='company/$present' width='70' height='68'/>"; the image was not as clear as when it was...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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,...

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.