Bonjour à tous.
J'essaie de redimensionner une image qui est stockée dans une table MySQL
mais j'obtiens une erreur lorsque je passe ma variable aux fonctions
imagecreatefromjpeg(), getimagesize() et imagecopyresized() . Il faut leurs
passer un fichier et non une variable mémoire. Mais je n'ai pas envie de
creer des fichiers pour faire cela, même temporairement. Je doit travailler
en memoire. Qq a-t-il une solution ?
<?php
if (isset($id)) {
require ("./conf/config.inc.php");
$res = mysql_query ("SELECT * FROM images WHERE id=$id");
if (mysql_num_rows($res)>0) {
header( "Content-Type: image/jpg");
$temp = mysql_result($res,0,pics);
$srcImg = imagecreatefromjpeg($temp);
$srcSize = getimagesize($temp);
$dstImg = imagecreatetruecolor(50,50);
imagecopyresized($dstImg, $srcImg, 0, 0, 0, 0, 50, 50, $srcSize[0],
$srcSize[1]);
imagejpeg($dstImg);
imagedestroy($scrImg);
imagedestroy($dstImg);
}
}
?>
Merci.
Damien
--
# Damien Viel
# da****@studioclick.fr
# http://www.studioclick.fr
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system ( http://www.grisoft.com).
Version: 6.0.543 / Virus Database: 337 - Release Date: 21/11/2003 5 2373
Damien Viel wrote: Bonjour à tous.
Hi. J'essaie de redimensionner une image qui est stockée dans une table MySQL mais j'obtiens une erreur lorsque je passe ma variable aux fonctions imagecreatefromjpeg(), getimagesize() et imagecopyresized() . Il faut leurs passer un fichier et non une variable mémoire. Mais je n'ai pas envie de creer des fichiers pour faire cela, même temporairement. Je doit travailler en memoire. Qq a-t-il une solution ?
I have absolutely no idea what that could possibly mean. Most of us read
and write good english here, but only a few possibly do so in French.
From the above babelfish gives:
" test redimensionner an image which is stored in a MySQL table but I
obtain an error when I pass my variable to the functions
imagecreatefromjpeg(), getimagesize() and imagecopyresized(). It is
necessary their to pass a file and not a variable memory. But I do not
want of creer files to do that, even temporarily. I must work in memory.
Does Qq have a solution? "
<?php if (isset($id)) { require ("./conf/config.inc.php"); $res = mysql_query ("SELECT * FROM images WHERE id=$id"); if (mysql_num_rows($res)>0) { header( "Content-Type: image/jpg"); $temp = mysql_result($res,0,pics); $srcImg = imagecreatefromjpeg($temp); $srcSize = getimagesize($temp); $dstImg = imagecreatetruecolor(50,50); imagecopyresized($dstImg, $srcImg, 0, 0, 0, 0, 50, 50, $srcSize[0], $srcSize[1]); imagejpeg($dstImg); imagedestroy($scrImg); imagedestroy($dstImg); } }
Im not an expert with the GD library, since I've found ImageMagick to be
so much better. Others feel free to comment.
--
Suni
Ok Thanks,
Sorry for the language....
Next time I will try in English.
Bests
Damien
--
# Damien Viel
# da****@studioclick.fr
# http://www.studioclick.fr
"Juha Suni" <ju*******@ilmiantajat.fi> a écrit dans le message de
news:3f***********************@news.song.fi... Damien Viel wrote: Bonjour à tous.
Hi.
J'essaie de redimensionner une image qui est stockée dans une table MySQL mais j'obtiens une erreur lorsque je passe ma variable aux fonctions imagecreatefromjpeg(), getimagesize() et imagecopyresized() . Il faut leurs passer un fichier et non une variable mémoire. Mais je n'ai pas envie de creer des fichiers pour faire cela, même temporairement. Je doit travailler en memoire. Qq a-t-il une solution ?
I have absolutely no idea what that could possibly mean. Most of us read and write good english here, but only a few possibly do so in French.
From the above babelfish gives: " test redimensionner an image which is stored in a MySQL table but I obtain an error when I pass my variable to the functions imagecreatefromjpeg(), getimagesize() and imagecopyresized(). It is necessary their to pass a file and not a variable memory. But I do not want of creer files to do that, even temporarily. I must work in memory. Does Qq have a solution? "
<?php if (isset($id)) { require ("./conf/config.inc.php"); $res = mysql_query ("SELECT * FROM images WHERE id=$id"); if (mysql_num_rows($res)>0) { header( "Content-Type: image/jpg"); $temp = mysql_result($res,0,pics); $srcImg = imagecreatefromjpeg($temp); $srcSize = getimagesize($temp); $dstImg = imagecreatetruecolor(50,50); imagecopyresized($dstImg, $srcImg, 0, 0, 0, 0, 50, 50, $srcSize[0], $srcSize[1]); imagejpeg($dstImg); imagedestroy($scrImg); imagedestroy($dstImg); } }
Im not an expert with the GD library, since I've found ImageMagick to be so much better. Others feel free to comment.
-- Suni
Juha Suni wrote: Damien Viel wrote: I have absolutely no idea what that could possibly mean. Most of us read and write good english here, but only a few possibly do so in French.
From the above babelfish gives: " test redimensionner an image which is stored in a MySQL table but I obtain an error when I pass my variable to the functions imagecreatefromjpeg(), getimagesize() and imagecopyresized(). It is necessary their to pass a file and not a variable memory. But I do not want of creer files to do that, even temporarily. I must work in memory. Does Qq have a solution? "
Thansk for the translation ;)
<?php if (isset($id)) { require ("./conf/config.inc.php"); $res = mysql_query ("SELECT * FROM images WHERE id=$id"); if (mysql_num_rows($res)>0) { header( "Content-Type: image/jpg"); $temp = mysql_result($res,0,pics); $srcImg = imagecreatefromjpeg($temp); $srcSize = getimagesize($temp); $dstImg = imagecreatetruecolor(50,50); imagecopyresized($dstImg, $srcImg, 0, 0, 0, 0, 50, 50, $srcSize[0], $srcSize[1]); imagejpeg($dstImg); imagedestroy($scrImg); imagedestroy($dstImg); } }
Try something like...
<?php
if(isset($id)) {
require("./conf/config.inc.php");
$result = mysql_query("SELECT * FROM images WHERE id = $id");
if(mysql_num_rows($result)>0) {
$tmpName = tempnam("/tmp", "IMAGE_");
$tmp = fopen($tmpName,"w");
fwrite($tmp,mysql_result($res,0,pics));
fclose($tmp);
$tmpSize = getImageSize($tmp);
$srcImg = imagecreatefromjpeg($tmpName);
$dstImg = imagecreatetruecolor(50,50);
imagecopyresized($dstImg,$srcImg,0,0,0,0,50,50,$tm pSize[0],tmpSize[1]);
header("Content-Type: image/jpg");
imagejpeg($dstImg);
imagedestroy($dstImg);
imagedestroy($srcImg);
unlink($tmpName);
}
}
?>
I have just made this fast... dont know if it work? :( I wont be back
before tomorrow... if there are any problems just contact me (maybe by
mail (tcr480 (at) yahoo (dot) dk
Regards,
Johan
Thanks,
Yes that should work, but it may have some trouble if the safe mode is
enabled.
Bests
Dams
--
# Damien Viel
# da****@studioclick.fr
# http://www.studioclick.fr
"Johan Holst Nielsen" <jo***@weknowthewayout.com> a écrit dans le message de
news:3f**********************@dread14.news.tele.dk ... Juha Suni wrote: Damien Viel wrote: I have absolutely no idea what that could possibly mean. Most of us read and write good english here, but only a few possibly do so in French.
From the above babelfish gives: " test redimensionner an image which is stored in a MySQL table but I obtain an error when I pass my variable to the functions imagecreatefromjpeg(), getimagesize() and imagecopyresized(). It is necessary their to pass a file and not a variable memory. But I do not want of creer files to do that, even temporarily. I must work in memory. Does Qq have a solution? " Thansk for the translation ;)
<?php if (isset($id)) { require ("./conf/config.inc.php"); $res = mysql_query ("SELECT * FROM images WHERE id=$id"); if (mysql_num_rows($res)>0) { header( "Content-Type: image/jpg"); $temp = mysql_result($res,0,pics); $srcImg = imagecreatefromjpeg($temp); $srcSize = getimagesize($temp); $dstImg = imagecreatetruecolor(50,50); imagecopyresized($dstImg, $srcImg, 0, 0, 0, 0, 50, 50, $srcSize[0], $srcSize[1]); imagejpeg($dstImg); imagedestroy($scrImg); imagedestroy($dstImg); } }
Try something like...
<?php if(isset($id)) { require("./conf/config.inc.php"); $result = mysql_query("SELECT * FROM images WHERE id = $id"); if(mysql_num_rows($result)>0) { $tmpName = tempnam("/tmp", "IMAGE_"); $tmp = fopen($tmpName,"w"); fwrite($tmp,mysql_result($res,0,pics)); fclose($tmp); $tmpSize = getImageSize($tmp); $srcImg = imagecreatefromjpeg($tmpName); $dstImg = imagecreatetruecolor(50,50);
imagecopyresized($dstImg,$srcImg,0,0,0,0,50,50,$tm pSize[0],tmpSize[1]); header("Content-Type: image/jpg"); imagejpeg($dstImg); imagedestroy($dstImg); imagedestroy($srcImg); unlink($tmpName); } }
?>
I have just made this fast... dont know if it work? :( I wont be back before tomorrow... if there are any problems just contact me (maybe by mail (tcr480 (at) yahoo (dot) dk
Regards, Johan
Answered on alt.comp.lang.php...
Please stop multiposting like this this is the 3rd copy of your
original post I found!
Learn how to crosspost and even better don't do it... This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: francescomoi |
last post by:
Hi.
I'm trying to build 'MySQL-python-1.2.0' on my Linux FC2:
----------------------------------
# export PATH=$PATH:/usr/local/mysql/bin/
# export mysqlclient=mysqlclient_r
# python setup.py...
|
by: mikey |
last post by:
Hi all,
I'm having great problems trying to install the latest MySQl RPM
package onto my Red Hat Linux OS.
There is already MySQL v 3.0 pre-installed with the RH Linux
distribution disk but I...
|
by: Yun Guan |
last post by:
Hello mysql gurus,
I am trying to run perl on mysql database on Red Hat box. I want to install
DBI and DBD:mysql using CPAN:
perl -MCPAN -e shell
cpan>install DBI
The above succeeded, but...
|
by: Mike Chirico |
last post by:
Interesting Things to Know about MySQL
Mike Chirico (mchirico@users.sourceforge.net)
Copyright (GPU Free Documentation License) 2004
Last Updated: Mon Jun 7 10:37:28 EDT 2004
The latest...
|
by: Saqib Ali |
last post by:
I installed mySQL and have it running.... but I think I made a
mistake somewhere along the line...... I believe I did follow the
instructions that were provided with the distribution at:...
|
by: Alex Hunsley |
last post by:
I am trying to install the DBD::mysql perl module. However, it claims I
need mysql.h:
cpan> install DBD::mysql
CPAN: Storable loaded ok
Going to read /home/alex/.cpan/Metadata
Database was...
|
by: ./Rob & |
last post by:
Hi gang:
I'm experiencing a problem with MySQL -- I updated MySQL from version 4.1.0
to 4.1.10 and now when I login as root it doesn't show all the databases I
should have access to, nor it...
|
by: trihanhcie |
last post by:
I m currently working on a Unix server with a fedora 3 as an os
My current version of mysql is 3.23.58. I'd like to upgrade the version
to 5.0.18.
After downloading from MYSQL.COM the package on...
|
by: manish deshpande |
last post by:
Hi,
When i'm installing MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm by the following command:
rpm -i MySQL-server-standard-5.0.24a-0.rhel3.i386.rpm the following error is being shown:
...
|
by: menzies |
last post by:
Hi, I"m new to this forum, but I have been trying all day to install DBD::mysql onto my Intel MacBook. I've read lots of forums pages and none have gotten me to a successful 'make test' or a...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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: 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...
|
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: 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...
|
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...
| |