Re: Making images smaller, and displaying them!
Hello Alvaro,
IrfanView looks like it might be useful to m.
I'm still trying to get a feel for the php/html landscape. It feels as
alien as switching to oop did for me! There's so much to know.
Getting the image into the html image control seems to be my main problem,
and <img src="thumbs.php ?file.gif"> looks very interesting. I've found
http://www.snipe.net/geek/scripts/pdfs/gdlib-php.pdf which I'll read now.
At present I'm getting header already sent erro messages.
Here's my attempt so far if you're interested (or feeling helpful...).
Well, back to the web to read and learn about how to use scripts..
Thanks,
Gregory.
<?php require_once('C onnections/connProperty.ph p'); ?>
<?php
# Constants
//define(IMAGE_BA SE, '/var/www/html/mbailey/images');
define(MAX_WIDT H, 150);
define(MAX_HEIG HT, 150);
$maxRows_PrpSum mary = 9;
$pageNum_PrpSum mary = 0;
if (isset($_GET['pageNum_PrpSum mary'])) {
$pageNum_PrpSum mary = $_GET['pageNum_PrpSum mary'];
}
$startRow_PrpSu mmary = $pageNum_PrpSum mary * $maxRows_PrpSum mary;
mysql_select_db ($database_conn Property, $connProperty);
$query_PrpSumma ry = "SELECT Prp.PreStreet House, Str.Name Street, sCi.Name
Borough, Cit.Name City,
ssC.Name District, sCy.Name County, Cry.Name
Country, PcX.Pic PcXPic,
Pic.Id PicId, Pic.FileName FileName,
Pic.FileLocatio n Location
FROM Property AS Prp
Left Outer Join Country Cry On Cry.Id = Prp.Cry
Left Outer Join sCountry sCy On sCy.Id = Prp.sCy
Left Outer Join ssCountry ssC On ssC.Id = Prp.ssC
Left Outer Join City Cit On Cit.Id = Prp.Cit
Left Outer Join sCity sCi On sCi.Id = Prp.sCi
Left Outer Join Street Str On Str.Id = Prp.Str
Left Outer Join PicToX PcX On PcX.TargetId =
Prp.Id And PcX.TargetType = 21
And PcX.Priority = 1
Left outer join Picture Pic On Pic.Id = PcX.Pic
";
$query_limit_Pr pSummary = sprintf("%s LIMIT %d, %d", $query_PrpSumma ry,
$startRow_PrpSu mmary, $maxRows_PrpSum mary);
$PrpSummary = mysql_query($qu ery_limit_PrpSu mmary, $connProperty) or
die(mysql_error ());
$row_PrpSummary = mysql_fetch_ass oc($PrpSummary) ;
if (isset($_GET['totalRows_PrpS ummary'])) {
$totalRows_PrpS ummary = $_GET['totalRows_PrpS ummary'];
} else {
$all_PrpSummary = mysql_query($qu ery_PrpSummary) ;
$totalRows_PrpS ummary = mysql_num_rows( $all_PrpSummary );
}
$totalPages_Prp Summary = ceil($totalRows _PrpSummary/$maxRows_PrpSum mary)-1;
?>
<html>
<head>
<title>Untitl ed Document</title>
</head>
<body>
<table width="487" border="2" align="left" bgcolor="#99FFC C" frame="below">
<tr><td width="291">Add ress</td></tr>
<?php do { ?>
<tr>
<td height="107"><? php echo $row_PrpSummary['House']; ?><br>
<?php echo $row_PrpSummary['Street']; ?><br>
<?php echo $row_PrpSummary['Borough']; ?><br>
<?php echo $row_PrpSummary['City']; ?><br>
<?php echo $row_PrpSummary['District']; ?><br>
<?php echo $row_PrpSummary['County']; ?> <?php echo
$row_PrpSummary['Country']; ?></td>
<!-- <td><img src="<?php echo $row_PrpSummary['FileName']; ?>" ></td> -->
<?php
$image_path = 'e:\property\\d ata\\images\\' .
$row_PrpSummary['FileName'];
$img = null;
$ext = strtolower(end( explode('.', $image_path)));
if ($ext == 'jpg' || $ext == 'jpeg') {
$img = @imagecreatefro mjpeg($image_pa th);
} else if ($ext == 'png') {
$img = @imagecreatefro mpng($image_pat h);
# Only if your version of GD includes GIF support
} else if ($ext == 'gif') {
$img = @imagecreatefro mpng($image_pat h);
}
# If an image was successfully loaded, test the image for size
if ($img) {
# Get image size and scale ratio
$width = imagesx($img);
$height = imagesy($img);
$scale = min(MAX_WIDTH/$width, MAX_HEIGHT/$height);
# If the image is larger than the max shrink it
if ($scale < 1) {
$new_width = floor($scale*$w idth);
$new_height = floor($scale*$h eight);
# Create a new temporary image
$tmp_img = imagecreatetrue color($new_widt h, $new_height);
# Copy and resize old image into new image
imagecopyresize d($tmp_img, $img, 0, 0, 0, 0,
$new_width, $new_height, $width, $height);
imagedestroy($i mg);
$img = $tmp_img;
}
}
# Create error image if necessary
if (!$img) {
$img = imagecreate(MAX _WIDTH, MAX_HEIGHT);
imagecoloralloc ate($img,0,0,0) ;
$c = imagecoloralloc ate($img,70,70, 70);
imageline($img, 0,0,MAX_WIDTH,M AX_HEIGHT,$c2);
imageline($img, MAX_WIDTH,0,0,M AX_HEIGHT,$c2);
}
//imagejpeg($img) ;
?>
<td>
<?php
# Display the image
imagejpeg($img) ;
?>
</td>
</tr>
<?php } while ($row_PrpSummar y = mysql_fetch_ass oc($PrpSummary) ); ?>
</table>
</body>
</html>
<?php
mysql_free_resu lt($PrpSummary) ;
?>
----- Original Message -----
From: Alvaro G Vicario
Newsgroups: comp.lang.php
Sent: Tuesday, October 28, 2003 4:27 PM
Subject: Re: Making images smaller, and displaying them!
*** Gregory escribió/wrote (12:23:56 28/10/2003):[color=blue]
> How can I display a resized image in a table, without writing it to
> disk first?[/color]
If you don't want to store thumbnails on disk you can create a script
to generate them on the fly and link to it:
<img src="thumbs.php ?file.gif">
There're many ways to create thumbs. I've found the easier one is using
the "display" utility from ImageMagick:
exec('convert -antialias -resize 100x80 +profile "*"
'.escapeshellar g($original).' '.escapeshellar g($thumb));
The above code writes thumbs on disk, it can't be difficult to redirect
output to stardard output.
[color=blue]
> I could get around this problem by creating smaller images in the
> windows app (non web) but I cannot find anything to do this. If you
> know of a dll or ocx etc that I could use, please let me know![/color]
You have tons of standalone apps but I don't know about libraries...
Have you checked XNview or IrfanView?
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Making images smaller, and displaying them!
Collapse
This topic is closed.
X
X
-
Guest replied -
Guest repliedRe: Making images smaller, and displaying them!
*** Gregory escribió/wrote (12:23:56 28/10/2003):[color=blue]
> How can I display a resized image in a table, without writing it to
> disk first?[/color]
If you don't want to store thumbnails on disk you can create a script
to generate them on the fly and link to it:
<img src="thumbs.php ?file.gif">
There're many ways to create thumbs. I've found the easier one is using
the "display" utility from ImageMagick:
exec('convert -antialias -resize 100x80 +profile "*"
'.escapeshellar g($original).' '.escapeshellar g($thumb));
The above code writes thumbs on disk, it can't be difficult to redirect
output to stardard output.
[color=blue]
> I could get around this problem by creating smaller images in the
> windows app (non web) but I cannot find anything to do this. If you
> know of a dll or ocx etc that I could use, please let me know![/color]
You have tons of standalone apps but I don't know about libraries...
Have you checked XNview or IrfanView?
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Leave a comment:
-
Guest repliedRe: Making images smaller, and displaying them!
Hi Steve,
I dont' want the client to have to upload the whole set of large images in
the first place, hence the server side (I hope, but I'm very new to php &
web stuff) reduction prior to transmission.
Gregory.
"Steve" <gr82meetu78@ya hoo.com> wrote in message
news:bb8f15bd.0 310280657.a99d8 84@posting.goog le.com...[color=blue]
> "Gregory" <php at neutrino-soft @@@ ware.co.uk> wrote in message[/color]
news:<4msnb.167 9$lm1.10633@war ds.force9.net>. ..[color=blue][color=green]
> > Hello,
> >
> > I've managed to build two web pages, one that can display images with
> > associated text data in a table, and one that can resize and display[/color][/color]
images[color=blue][color=green]
> > without the text. I'd like to resize the images as I go, without writing
> > them to disk on the server. Do I need to prepare all of the resized[/color][/color]
images[color=blue][color=green]
> > before I display the data from the select (which is put into an array by
> > php). How can I display a resized image in a table, without writing it[/color][/color]
to[color=blue][color=green]
> > disk first?
> >
> > I could get around this problem by creating smaller images in the[/color][/color]
windows[color=blue][color=green]
> > app (non web) but I cannot find anything to do this. If you know of a[/color][/color]
dll[color=blue][color=green]
> > or ocx etc that I could use, please let me know!
> >
> > Thank you.
> >
> > Gregory.
> >
> > London, UK.[/color]
> Well I would first try adjusting the size the size on the fly.
> Maybe even something client side like <img src/images/myimage.jpg
> width="50" height="50">
> Assuming an image is 100x100 that would cause the browser to display
> the image at 1/2 size. Note those are fixed sizes not percentages.
> I'm not sure if using percentages is cross browser compatible, but
> it's worth a shot.[/color]
Leave a comment:
-
Guest repliedRe: Making images smaller, and displaying them!
"Gregory" <php at neutrino-soft @@@ ware.co.uk> wrote in message news:<4msnb.167 9$lm1.10633@war ds.force9.net>. ..[color=blue]
> Hello,
>
> I've managed to build two web pages, one that can display images with
> associated text data in a table, and one that can resize and display images
> without the text. I'd like to resize the images as I go, without writing
> them to disk on the server. Do I need to prepare all of the resized images
> before I display the data from the select (which is put into an array by
> php). How can I display a resized image in a table, without writing it to
> disk first?
>
> I could get around this problem by creating smaller images in the windows
> app (non web) but I cannot find anything to do this. If you know of a dll
> or ocx etc that I could use, please let me know!
>
> Thank you.
>
> Gregory.
>
> London, UK.[/color]
Well I would first try adjusting the size the size on the fly.
Maybe even something client side like <img src/images/myimage.jpg
width="50" height="50">
Assuming an image is 100x100 that would cause the browser to display
the image at 1/2 size. Note those are fixed sizes not percentages.
I'm not sure if using percentages is cross browser compatible, but
it's worth a shot.
Leave a comment:
-
Making images smaller, and displaying them!
Hello,
I've managed to build two web pages, one that can display images with
associated text data in a table, and one that can resize and display images
without the text. I'd like to resize the images as I go, without writing
them to disk on the server. Do I need to prepare all of the resized images
before I display the data from the select (which is put into an array by
php). How can I display a resized image in a table, without writing it to
disk first?
I could get around this problem by creating smaller images in the windows
app (non web) but I cannot find anything to do this. If you know of a dll
or ocx etc that I could use, please let me know!
Thank you.
Gregory.
London, UK.
Tags: None
Leave a comment: