I am looking for a way to resize uploaded (jpg) images automatically.
My ISP hasn't got any preinstalled image manipulation library installed
on the (centos) serverhost, so I either have to come up with something
in PHP, Perl, Java or some other (CGI) applet/application.
GD is installed and active, but I can't find any suitable function so far.
Preferrably I stick to PHP, but if it isn't possible I would opt for any
of the alternatives.
Any good tips, pointers, links?
Thanks!
Sh. 2 1691
Schraalhans Keukenmeester wrote: I am looking for a way to resize uploaded (jpg) images automatically. My ISP hasn't got any preinstalled image manipulation library installed on the (centos) serverhost, so I either have to come up with something in PHP, Perl, Java or some other (CGI) applet/application.
GD is installed and active, but I can't find any suitable function so far.
Preferrably I stick to PHP, but if it isn't possible I would opt for any of the alternatives.
Any good tips, pointers, links? Thanks! Sh.
Whoops, sorry, found the imagecreatefrom and imagecopyresized functions.
My bad. Simply missed those on first reading the imagefunction chapters.
Rgds
Sh.
Hello Schraalhans,
Please use following function which was developed by me you can use it
directly.
If u have any problem Please contact me on mitul[at]siliconinfo[dot]com
function thumbgenerator($forcedwidth, $forcedheight, $sourcefile,
$destfile, $imgcomp)
{
$g_imgcomp=100-$imgcomp;
$g_srcfile=$sourcefile;
$g_dstfile=$destfile;
$g_fw=$forcedwidth;
$g_fh=$forcedheight;
if(file_exists($g_srcfile))
{
$g_is=getimagesize($g_srcfile);
if(($g_is[0]-$g_fw)>=($g_is[1]-$g_fh))
{
$g_iw=$g_fw;
$g_ih=($g_fw/$g_is[0])*$g_is[1];
}
else
{
$g_ih=$g_fh;
$g_iw=($g_ih/$g_is[1])*$g_is[0];
}
$src=explode(".",$g_srcfile);
$var=count($src);
if($src[$var-1]=='gif' || $src[$var-1]=='GIF')
{
$img_src=ImageCreateFromGIF($g_srcfile);
//$img_src= ImageColorAllocate($img_src, 250, 250, 250);
$img_dst=imagecreate($g_iw,$g_ih);
$img_dst1 = ImageColorAllocate($img_dst, 255, 255, 255);
}
if($src[$var-1]=='png')
{
$img_src=ImageCreateFromPNG($g_srcfile);
$img_dst=imagecreate($g_iw,$g_ih);
$img_dst1 = ImageColorAllocate($img_dst,255, 255, 255);
}
if($src[$var-1]=='jpg' || $src[$var-1]=='JPG')
{
$img_src=imagecreatefromjpeg($g_srcfile);
$img_dst=imagecreate($g_iw,$g_ih);
$img_dst = &imageCreateTrueColor( $g_iw, $g_ih);
}
imagecopyresampled($img_dst, $img_src, 0, 0, 0, 0, $g_iw, $g_ih,
$g_is[0], $g_is[1]);
if($src[$var-1]=='jpg' || $src[$var-1]=='JPG')
{
imagejpeg($img_dst, $g_dstfile, $g_imgcomp);
}
if($src[$var-1]=='png')
{
imagepng($img_dst, $g_dstfile, $g_imgcomp);
}
if($src[$var-1]='gif' || $src[$var-1]=='GIF')
{
imagegif($img_dst, $g_dstfile, $g_imgcomp);
}
imagedestroy($img_dst);
return true;
}
else
return false;
} This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Raaijmakers, Vincent \(GE Infrastructure\) |
last post by:
Who can explain the huge increase in size when I convert a JPG into a PNG format using PythonMagick:
I read the JPG from a video server and has a resolution of 352x240, size is about 15k
After my...
|
by: Kenny |
last post by:
I have been trying to write a script that will increase the size of
and image when you mouse over it, and decrease it to original size,
when you mouse out. After a couple of attempts, this is what...
|
by: Greg Scharlemann |
last post by:
Given some recent success on a simple form validation (mainly due to
the kind folks in this forum), I've tried to tackle something a bit
more difficult. I'm pulling data down from a database and...
|
by: Paolo Pignatelli |
last post by:
I am trying to get an output/file like this (below) in an XML file
(MyXmlFile.xml) (which I will use for a slide show)
--
<gallery timer="3" order="sequential" fadetime="2" looping="yes"...
|
by: Doug van Vianen |
last post by:
Hi,
I have the following coding on a web page. It causes two pictures (pic1.jpg
and pic2.jpg)
to show, one above the other and then when one clicks on the top picture is
squeezes to
the left...
|
by: phillip.s.powell |
last post by:
<style>
div div table tr td a.navbar, div div table tr td font {display:
none;}
</style>
<div class="navigationbar" style="background-color:Black; position:
absolute; left:50%; top:127px;...
|
by: Anthony |
last post by:
I am using the following code to display fading pictures on a team
website. Can someone show me how to modify it such that I can display
the names of each employee when the picture changes? This...
|
by: oscartheduck |
last post by:
Hi folks,
I'm trying to alter a program I posted about a few days ago. It
creates thumbnail images from master images. Nice and simple.
To make sure I can match all variations in spelling of...
|
by: empiresolutions |
last post by:
I am working with a TIF to JPG conversion that will result in the JPG being printed from a web page. My issue is the final JPG image prints VERY blurry.
The TIF file that has the following...
|
by: kombu67 |
last post by:
I'm reading a series of images from a MS SQL table and saving them to
directory. These are staff ID pictures from our security card app.
Once I've extracted the ID photo from the security app to...
|
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,...
|
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$) {
}
...
|
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...
|
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
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
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,...
| |