1

I'm going to try to be simple.

I'm making a website for a photographer and there are a LOT of pictures (130) and these images are too heavy, they weigh between 500'000 and 6'000'000 octets and my browser can't handle it.

Someone gave me the advice to reduce the resolution, but I don't have time to reduce manually by using Photoshop. So I thought I could make a php script to reduce the resolution.. I'm not an expert in PHP so I don't really understand how it works to connect my PHP code and my images on the html page.

Here an exemple of my code (there is 130 times this code on the page) :

<!-- start : works-item -->
    <div  class="works-item works-item-one-third zoom fashion ">
            <img alt="" title="" class="img-responsive" src="images/jeremy/Fashion/IMG_0300-332-11.jpg"/>
            <a class="venobox" data-gall="portfolio-fashion" href="images/jeremy/Fashion/IMG_0300-332-11.jpg">
                <div class="works-item-inner valign">
                  <p class="white"><span class="black-bg">Fashion</span></p>
                </div>
            </a>
    </div>
<!-- end : works-item --> 

I thought I can use that kind of script for the PHP, but I don't really know if it works and I can't find how to include this PHP code in the HTML

<?php
// Création d'une image vide et ajout d'un texte
$im = imagecreatetruecolor(120, 20);
$text_color = imagecolorallocate($im, 233, 14, 91);
imagestring($im, 1, 5, 5,  $text_color);

// Définit le contenu de l'en-tête - dans ce cas,  image/jpeg
header('Content-Type: image/jpg');

// On ne fournit pas le nom du fichier (utilisation de la valeur NULL),
// puis, on définit la qualité à 75%
imagejpeg($im, NULL, 5);


?>

I would really appreciate if somebody could help me ! =)

Thanks !

Jérémy

jj_jaq
  • 41
  • 1
  • 1
  • 4
  • FYI you can bulk resize with photoshop too. If you want these to be ALWAYS downsized you're probably better off resizing the files as you'll use less disk space too. – DaOgre Mar 10 '15 at 23:12

0 Answers0