473,473 Members | 1,974 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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.



Jul 17 '05 #1
4 7298
"Gregory" <php at neutrino-soft @@@ ware.co.uk> wrote in message news:<4m******************@wards.force9.net>...
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.

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.
Jul 17 '05 #2
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" <gr*********@yahoo.com> wrote in message
news:bb*************************@posting.google.co m...
"Gregory" <php at neutrino-soft @@@ ware.co.uk> wrote in message

news:<4m******************@wards.force9.net>...
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.

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.

Jul 17 '05 #3
*** Gregory escribió/wrote (12:23:56 28/10/2003):
How can I display a resized image in a table, without writing it to
disk first?
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 "*"
'.escapeshellarg($original).' '.escapeshellarg($thumb));

The above code writes thumbs on disk, it can't be difficult to redirect
output to stardard output.

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!


You have tons of standalone apps but I don't know about libraries...
Have you checked XNview or IrfanView?
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #4
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('Connections/connProperty.php'); ?>
<?php
# Constants
//define(IMAGE_BASE, '/var/www/html/mbailey/images');
define(MAX_WIDTH, 150);
define(MAX_HEIGHT, 150);

$maxRows_PrpSummary = 9;
$pageNum_PrpSummary = 0;
if (isset($_GET['pageNum_PrpSummary'])) {
$pageNum_PrpSummary = $_GET['pageNum_PrpSummary'];
}
$startRow_PrpSummary = $pageNum_PrpSummary * $maxRows_PrpSummary;

mysql_select_db($database_connProperty, $connProperty);
$query_PrpSummary = "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.FileLocation 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_PrpSummary = sprintf("%s LIMIT %d, %d", $query_PrpSummary,
$startRow_PrpSummary, $maxRows_PrpSummary);
$PrpSummary = mysql_query($query_limit_PrpSummary, $connProperty) or
die(mysql_error());
$row_PrpSummary = mysql_fetch_assoc($PrpSummary);

if (isset($_GET['totalRows_PrpSummary'])) {
$totalRows_PrpSummary = $_GET['totalRows_PrpSummary'];
} else {
$all_PrpSummary = mysql_query($query_PrpSummary);
$totalRows_PrpSummary = mysql_num_rows($all_PrpSummary);
}
$totalPages_PrpSummary = ceil($totalRows_PrpSummary/$maxRows_PrpSummary)-1;
?>
<html>
<head>
<title>Untitled Document</title>
</head>

<body>
<table width="487" border="2" align="left" bgcolor="#99FFCC" frame="below">
<tr><td width="291">Address</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\\data\\images\\' .
$row_PrpSummary['FileName'];
$img = null;
$ext = strtolower(end(explode('.', $image_path)));
if ($ext == 'jpg' || $ext == 'jpeg') {
$img = @imagecreatefromjpeg($image_path);
} else if ($ext == 'png') {
$img = @imagecreatefrompng($image_path);
# Only if your version of GD includes GIF support
} else if ($ext == 'gif') {
$img = @imagecreatefrompng($image_path);
}

# 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*$width);
$new_height = floor($scale*$height);

# Create a new temporary image
$tmp_img = imagecreatetruecolor($new_width, $new_height);

# Copy and resize old image into new image
imagecopyresized($tmp_img, $img, 0, 0, 0, 0,
$new_width, $new_height, $width, $height);
imagedestroy($img);
$img = $tmp_img;
}
}

# Create error image if necessary
if (!$img) {
$img = imagecreate(MAX_WIDTH, MAX_HEIGHT);
imagecolorallocate($img,0,0,0);
$c = imagecolorallocate($img,70,70,70);
imageline($img,0,0,MAX_WIDTH,MAX_HEIGHT,$c2);
imageline($img,MAX_WIDTH,0,0,MAX_HEIGHT,$c2);
}
//imagejpeg($img);
?>

<td>
<?php
# Display the image
imagejpeg($img);
?>
</td>
</tr>
<?php } while ($row_PrpSummary = mysql_fetch_assoc($PrpSummary)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($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):
How can I display a resized image in a table, without writing it to
disk first?
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 "*"
'.escapeshellarg($original).' '.escapeshellarg($thumb));

The above code writes thumbs on disk, it can't be difficult to redirect
output to stardard output.

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!


You have tons of standalone apps but I don't know about libraries...
Have you checked XNview or IrfanView?
--
--
-- Álvaro G. Vicario - Burgos, Spain
--
Jul 17 '05 #5

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

Similar topics

7
by: Vinay | last post by:
Hi All: I have a small application that stores images either in the database or as files (depending on the user preference). I'm in the process of providing a web interface to this application....
5
by: david | last post by:
Can I use WriteFile methods? It seems that it does not work. For example, the following code only dispay one figure. Response.WriteFile("images/image002.jpg") Response.Write("<br><p>")...
15
by: mleaver | last post by:
I want to open a second window and display a binary image that is returned from a java program via XMLRPC. The data returned is a binary encoded base64 png file. If I write the data out to a file...
5
by: Oenone | last post by:
This may be a bit of a long shot... I've been working with the excellent new ReportView libraries in VS2005. Until this afternoon I've been extremely happy with everything I've seen them do....
1
by: Xah Lee | last post by:
The following is a program to generate thumbnail images for a website. Useful, if you want to do that. It is used to generate the thumbnails for my “Banners, Damsels, and Mores†project...
7
by: Helmut Giese | last post by:
Hello out there, I know that I can replace an image with another using e.g. onMouseOver="swapIn(...)" and onMouseOut="swapOut(...)" Is there anything I can do if Javascript is disabled? - I...
48
by: mantrid | last post by:
Hello Is there a way to prevent users copying a full size image from a web page. Displaying the image with a smaller width and height only affects the image as viewed, the actual full size image...
7
by: Stephen.Schoenberger | last post by:
Hello, I am reading in a bitmap image and storing it as a bitmap in C#. I need to perform some mathmatical operations on that image but it needs to be broken up into smaller fragments (16x16)....
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...
0
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...
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,...
1
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...
0
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...
0
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,...
1
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.