...

View Full Version : is it possible to reduce the file size of an image without manually doing it?



LJackson
09-14-2009, 08:59 PM
Hi,

ok i have a website with many images on it, these images are pulled from xml files and i have no control over the size of them, meaning my pages load slowley :(

so what i was thinking of doing is:

download each individual image
somehow reduce the image quality? therefor its size without doing each one manually
upload the new images to use on my site


does this sound possible?
thanks

mlseim
09-14-2009, 09:47 PM
Are they pulled from XML with a PHP script?

Maybe PHP GD to put them into a cache ...
How often do they change, or are added/deleted?

Using GD on-the-fly for every page load would be
extensive, but processing them periodically into a
"cache" directory would make things fast.

LJackson
09-14-2009, 10:14 PM
hi mate,

i use amazon rss feeds such as this one (http://www.amazon.co.uk/rss/bestsellers/dvd/ref=pd_ts_rss_link) to pullout the top 3 items/images and these are stored in my db.

i have a script which updates my db once a day, it deletes all records and inserts the new set.

thanks
Luke

shakir
09-15-2009, 09:52 AM
hi mate,

i use amazon rss feeds such as this one (http://www.amazon.co.uk/rss/bestsellers/dvd/ref=pd_ts_rss_link) to pullout the top 3 items/images and these are stored in my db.

i have a script which updates my db once a day, it deletes all records and inserts the new set.

thanks
Luke
Your image files are storing in DB or only the path?

LJackson
09-15-2009, 11:34 AM
hi shakir,

its only the img path thats stored im my db.

thanks

mlseim
09-15-2009, 01:37 PM
So you already have the PHP script that parses the <img> and text?

What does that script look like?
It's within that script where you'll use PHP GD to resize the image.

LJackson
09-15-2009, 10:54 PM
the script which gets the image and title looks like this


//Entertainment Update

$today = date("d-M-Y, h:i a");

$feeds = array(
"http://www.amazon.co.uk/rss/bestsellers/dvd/ref=pd_nr_rss_link", "http://www.amazon.co.uk/rss/new-releases/dvd/ref=pd_nr_rss_link","http://www.amazon.co.uk/rss/most-gifted/dvd/ref=pd_mg_rss_link", "http://www.amazon.co.uk/rss/bestsellers/music/ref=pd_ts_rss_link", "http://www.amazon.co.uk/rss/new-releases/music/ref=pd_nr_rss_link", "http://www.amazon.co.uk/rss/most-gifted/music/ref=pd_mg_rss_link", "http://www.amazon.co.uk/rss/bestsellers/videogames/ref=pd_ts_rss_link", "http://www.amazon.co.uk/rss/new-releases/videogames/ref=pd_nr_rss_link", "http://www.amazon.co.uk/rss/most-gifted/videogames/ref=pd_mg_rss_link",
"http://www.amazon.co.uk/rss/bestsellers/dvd/383380011/ref=pd_ts_rss_link",
"http://www.amazon.co.uk/rss/new-releases/dvd/383380011/ref=pd_nr_rss_link",
"http://www.amazon.co.uk/rss/most-gifted/dvd/383380011/ref=pd_mg_rss_link",
"http://www.amazon.co.uk/rss/bestsellers/books/ref=pd_ts_rss_link",
"http://www.amazon.co.uk/rss/new-releases/books/ref=pd_nr_rss_link",
"http://www.amazon.co.uk/rss/most-gifted/books/ref=pd_mw_rss_link"
);



$today = date("d-M-Y, h:i a");

$itemno = 1;
$itemtype = 0;
$product_Number = 1;

foreach ($feeds as $feed)
{
$count = 1;

$feedreader = simplexml_load_file("$feed");
$p_cnt = count($feedreader->channel->item);
//print "<p>$p_cnt</p>";


if ($p_cnt > 3)
{
$items = 3;
$empty = (3 - $items);
}
else
{
$items = (3 - $p_cnt);
$empty = (3 - $p_cnt);
}
print "<p>$empty</p>";

foreach ($feedreader->channel->item as $item)
{

$title = addslashes ($item->title);
$title = preg_replace('/#\d+:\s/', "", $title);
$photosource = get_string_between($item->description, '<img src="','"');
$otherinfo = get_string_between($item->description, '<span class="riRssContributor">','</span>');
}

there is more to this script but the rest isnt relivant (i dont think)

cheers
Luke

mlseim
09-16-2009, 02:26 AM
I'm sort of confused because when I look at those feeds
and view the images, they are all sort of small images ...

Example of 2 images from the feeds ...

http://ecx.images-amazon.com/images/I/51gjCyxx3uL._SL160_SS150_.jpg
http://ecx.images-amazon.com/images/I/41pfwxv1-iL._SL160_SS150_.jpg

So you mentioned that they load slow (meaning they are large images)?
Are the examples I showed what the images are?

LJackson
09-16-2009, 09:13 PM
yes mate those i believe are the ones, my pages take approx 140sec at 56k (i think) which is slow, and the images are approx 8kb each which isnt much but when you have 45 of them it takes its toll, thats why i wanted some way to reduce the size/quality of the images.

thanks
Luke

mlseim
09-17-2009, 12:16 AM
Luke ...

I've heard that in the U.S., only 10% of users still use dial-up.
Mostly rural users that have no DSL or Cable access.

I'm not sure where you live, but I would say that this is a non-issue in your case.

Because those images will be constantly changing, using GD to process them into
75% quality (reduced quality) will actually take more processing time than loading
the 8K images. That's where my thoughts were with post #8.

If the images were really huge, using PHP GD would be the most efficient method.
In your case, I think PHP GD would make things even slower.

Give me a link to your site and I'll do some timing tests with DSL and Broadband.
Maybe other viewers have a better perspective on this.

LJackson
09-17-2009, 03:59 PM
i live in the UK, where things are a bit slower getting to us :D i am lucky enough to have Broadband but some dont.

you mean will all the help youve given me in the past several months you dont know my url? shocking :D

here (http://www.kernow-connect.com/entertainment.php)it is mate

cheers
Luke

mlseim
09-18-2009, 04:10 AM
Sorry Luke,
I see so many URL's, I didn't make the connection at first.

Viewing your site on my DSL, which is faster than dial-up,
but slower than cable broadband ... it loads almost instantly.

I used to have dial-up for over 10 years ... and I realized then, and
expected those pages to load slow. In your case, I really wouldn't
spend the energy to make them smaller. It's just not worth it.

Take that time to fix the top menu tabs and background color.
See the attached image below.

Apostropartheid
09-18-2009, 01:50 PM
In the UK, broadband penetration should be even higher. Don't worry about it: people still on dialup will be used to that speed.

LJackson
09-18-2009, 06:32 PM
oh thats ok :)

thanks for running those tests appreciate it :)
just out of curiosity which browser was that using mlseim?

thanks guys
Luke

mlseim
09-19-2009, 02:14 AM
IE8.0

But here's the other strange thing.
On one PC I have, it does that on FF, but not on my other PC.
strange.

Apostropartheid
09-19-2009, 01:20 PM
Maybe it's the resolution of the browser's real estate?

mlseim
09-19-2009, 05:05 PM
My PC is new (Vista, IE8) with a huge LCD monitor.
The web page in question sits in the middle with lots of space on each side.
Yet, that menu is crunched onto 2 lines like in the screenshot I have.

Here's another screenshot using FireFox on the same PC (see below).
That's a shot of my whole browser (monitor).

LJackson
09-21-2009, 01:09 AM
hmmm interesting...

im running vista and ive just checked it in IE8 and it looks fine? wonder why that is, is there anything that i can do to prevent this?

(sorry just seen your earlier post mlseim about the two different results on your two pcs very strange why it would be displaying differently in the same browser :( )

@Apostropartheid
what do you mean mate?

cheers
Luke

mlseim
09-21-2009, 02:50 AM
First, see the HTML part of the page:

<div id="menu_r" class="byitem">
<ul class="right">
<li class="byitem"><a href="index.php">By Item</a></li>
<li class="store"><a href="stores.php">By Store</a></li>
<li class="brand"><a href="brand.php">By Brand</a></li>
</ul>
</div>

Then ...
Look below at the numbers in red.
Why would the class width be wider than the id width?
Maybe this is part of the problem?


#menu_r {
float:right;
width:208px;
font-size:13px;
line-height:normal;
}
#menu ul{
margin:0;
padding:15px 5px 0;
list-style:none;
float:left;
width:708px;
}
#menu_r ul {
margin:0;
padding:15px 5px 0;
list-style:none;
float:right;
width:208px;
}
#menu .right {
float:right;
width:220px;
}

LJackson
09-21-2009, 07:03 PM
ah, i will check this out didnt relise i was still using
#menu .right {

thanks mate
Luke

edit
===
ok ive changed it to 208px is there any change?

cheers mate



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum