I have like 50000 images on my server, and each image is about 7mb of size. I made a gallery script based on the famous html code for displaying image :
<img src="image.jpg" width="200" height="150">
Even after setting the width and the height, the image is till taking time to display, because it's always download the 7mb sized image.
So, I'm here to ask you, Experts, if there is any way to display these images in a form of thumbnail with a lower quality, so it can be displayed quickly. I would like to do that without creating thumbnails of those 50000 images.
I appreciate any help or idea from your behalf.
I hope you all find my question interesting and i hope that we can find out a solution for this problem.
Thank you very much.
5 3876
No. The only thing you can do is have images resized smaller.
you can try this simple script if you have the jnow how of GD library
Using Imagecopyresize d () -
<?php
-
// The file you are resizing
-
$file = 'your.jpg';
-
-
//This will set our output to 45% of the original size
-
$size = 0.45;
-
-
// This sets it to a .jpg, but you can change this to png or gif
-
header('Content-type: image/jpeg');
-
-
// Setting the resize parameters
-
list($width, $height) = getimagesize($file);
-
$modwidth = $width * $size;
-
$modheight = $height * $size;
-
-
// Creating the Canvas
-
$tn= imagecreatetruecolor($modwidth, $modheight);
-
$source = imagecreatefromjpeg($file);
-
-
// Resizing our image to fit the canvas
-
imagecopyresized($tn, $source, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
-
-
// Outputs a jpg image, you could change this to gif or png if needed
-
imagejpeg($tn);
-
?>
-
Using Imagecopyresamp led () -
<?php
-
// The file you are resizing
-
$file = 'yourfile.jpg';
-
-
//This will set our output to 45% of the original size
-
$size = 0.45;
-
-
// This sets it to a .jpg, but you can change this to png or gif
-
header('Content-type: image/jpeg');
-
-
// Setting the resize parameters
-
list($width, $height) = getimagesize($file);
-
$modwidth = $width * $size;
-
$modheight = $height * $size;
-
-
// Resizing the Image
-
$tn = imagecreatetruecolor($modwidth, $modheight);
-
$image = imagecreatefromjpeg($file);
-
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height);
-
-
// Outputting a .jpg, you can make this gif or png if you want
-
//notice we set the quality (third value) to 100
-
imagejpeg($tn, null, 100);
-
?>
-
optionally you an use phpthumb also see here
regards,
Omer Aslam
I still think the most optimal way is to generate thumbnails right after they're uploaded. Why? Because if you generate thumbnails on the fly, all the 7mb still have to be loaded into memory and considerable amount of processing has to be done each time a user views an image.
yes seoquake i agree ,
that is why i have added a link to phpthumb in the end , whatever h likes , choices he have.
regards,
Omer Aslam
Better way is that u can convert all these images in .png format.Because, Noone is going to use .jpg or .jpeg formats.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ming |
last post by:
Hi All,
I want to write a PHP webpage which allows people to upload images (no
matter what formats) to me and at the same time converts any non-jpeg
image to JPEG.
Here's what I have:
$FileDest = "/uploads/1.gif";
if (!move_uploaded_file($_FILES, $FileDest)):
|
by: Lucas Cowald |
last post by:
Hi,
Using ASP and VBScript. How to convert JPEG image into a binary data? Is it
possible with a command from ASP / VBScript without having to put it into a
database first?
I want to take the JPEG image from a folder, convert it into a binary data,
and stream it to the browser. How can I do it? Can you show a short code?
Thank you for your help.
|
by: Onwuka Emeka |
last post by:
is there a way to reduce or modify the color depth of a jpeg image, i
currently need to programatically change the color depth of a jpeg image
from 24bits to 8bits. any help would be appreciated
|
by: spgedwards |
last post by:
I am trying to run a basic script that displays an existing jpeg image
and writes some text over it. Sounds simple, but I cannot seem to be
able to colour the font correctly. In the example below it should be
black but it comes out orange. In fact, even if I change the colour to
0, 0, 255 it's orange.
I've read in the PHP documentation (the user contributed notes) that
there are issues with jpeg font colouring. But I've not seen any...
|
by: RaulAbHK |
last post by:
Dear all,
I guess this is a basic question with an easy answer but I am a
beginner and I would much apreciate your feedbacks.
Let's say I have a library with some functionality to perform some
image processing on jpeg images.
One of functions in the library is similar to this:
myfunction_effect (&out_instance, &mysettings, I8 *buf_in, I32
| |
by: nma |
last post by:
Hiya,
Can anyone help me in this..i'm stuck
I have created a table in SQL server that contain field name (shotSelectedKeyfrm -int type, and imgSelectedKeyfrm-varchar(255) type) like below:
Column1 Column2
32
340
|
by: =?Utf-8?B?TWFyazEyMw==?= |
last post by:
I have two pieces of VB.NET code below:
a) Sends an email
b) Returns a programmatically created jpeg image to a webpage.
How can I embed the programmatically created jpeg into an HTML formatted
email (without saving the jpeg to disk)?
Code a)
======
|
by: Puneeth kamath |
last post by:
I am working on pdf to xml conversion. I achieved pdf to text by using pdf clown samples. Now I am able to extract the pdf to text and image as well.
But the problem is,the saved image is blurry.
else if (content is it.stefanochizzolini.clown.documents.contents.objects.GraphicsObject)
{
/*=============================================================================
* TO...
|
by: santhanalakshmi |
last post by:
Hi,
I am running Apache and the Active Perl. In Apache, CGI folder, i had one JPEG image. I wants to display this JPEG image in my browser as the header.
use CGI qw(:all);
print "Content-type: text/html\n\n";
print "<body bgcolor="FFFF">;
print "<img src=\cgi-bin\header.jpg>";
print "</body>;
|
by: HaLo2FrEeEk |
last post by:
I've got an image that I want to load, it's a JPEG image and it has a solid background of color rgb(11, 12, 14). I want to make the background transparent and outpt the image as a PNG. I've tried this code:
header("Content-Type: image/png");
$im = imagecreatefromjpeg("http://www.bungie.net/stats/reach/nightmap.ashx");
$bg = imagecolorallocate($im, 11, 12, 14);
imagesavealpha($im, true);
imagecolortransparent($im, $bg);
imagepng($im);
...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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...
|
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...
|
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();...
|
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: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |