473,749 Members | 2,597 Online
Bytes | Software Development & Data Engineering Community
+ 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 7334
"Gregory" <php at neutrino-soft @@@ ware.co.uk> wrote in message news:<4m******* ***********@war ds.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*********@ya hoo.com> wrote in message
news:bb******** *************** **@posting.goog le.com...
"Gregory" <php at neutrino-soft @@@ ware.co.uk> wrote in message

news:<4m******* ***********@war ds.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 "*"
'.escapeshellar g($original).' '.escapeshellar g($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('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):
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 "*"
'.escapeshellar g($original).' '.escapeshellar g($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
2339
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. 1. If the images are stored in the DB then, every an image is requested, it will need to be pulled out and a temp file created and then displayed? What is the best way to do this?
5
2948
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>") Response.WriteFile("images/image003.jpg") Response.Write("<br><p>") Any help? Thanks
15
9807
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 on my server, I can display it using the following javascript: var windowHandle = window.open('about:blank','windowName','width=250,height=250'); windowHandle.document.write('<img name="myImage" src="images/test.png">');
5
2558
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. I've just run into a problem with generating PDF files that contain charts however, as Microsoft apparently ran out of time while working on the PDF report generator and didn't manage to get image compression working...
1
3232
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 gallery. ( http://xahlee.org/Periodic_dosage_dir/lanci/lanci.html ) Comments and versions in other lang welcome. Xah
7
2673
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 guess I could use 'noscript' to provide a link which opens an external window to display the second image' - any other possibilty?
48
2334
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 file is still downloaded. I know I can get around it by having two versions of an image, the full size one and a smaller on for display purposes. but is there a way around having to have two images and use the full ssize one and stop it being...
7
8433
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). On each of these fragments I need to perform my work, then write back the manipulated fragment to a new image. I have tried some different techniques but so far no luck. Any advice would be great! Thanks.
3
3581
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 little website: 1. Small: DOWNsize of original image to be used as a thumbnail. 2. Medium: DOWNsize of original image to be used as user avatars/icons in forums or profiles.
0
8833
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
jinu1996
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9256
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6079
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3320
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.