Jump to content

Pixelated Product's Images


Digital360Europe

Recommended Posts


I am a newbie to Prestashop and I would like your help. 😕

On the site where I develop Prestashop 1.7.6.2, I have used a Module that compressed all the photos of the products to provide better loading time. 
Unforulnaly the result is very bad and the images are pixelated.

I wonder if there is a way to restore the product's images to their original resolution.

I have checked from my FTP and the original photos exist.🙏

Link to comment
Share on other sites

I am a newbie to Prestashop and I need your help. 😕 even if my question seems silly!!! 😒

On the site where I am customizing, Prestashop 1.7.6.2, I have used a Module that compressed all the photos of the products to provide better loading time. 
Unfortunaly the result is very bad and the images are pixelated.

I wonder if there is a way to restore the product's images to their original resolution.

I have checked from my FTP and the original photos exist.🙏

Link to comment
Share on other sites

If you have chosen a webp format compression format, they will still remain on FTP.
You won't be able to regenerate 5000 images with Prestashop.
You will be hit with an expiration error of max_execution_time.

Link to comment
Share on other sites

Here is a script that removes all webp images and all thumbnail images.
Does not delete the original image.

If the script finishes with an error (time runs out), no matter, you can run it again.
Checks if there is an image, if any, deletes it, otherwise it continues.

Save the script as eg delete-image.php
Save this script to the Prestashop main directory.

 

If you just want to test the script, just 3x comment on unlink.

//unlink($imag....

 

I recommend backing up the ./img/p folder !!!

<?php
  ini_set('display_errors', 1);
  ini_set('display_startup_errors', 1);
  error_reporting(E_ALL);

  include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'config.inc.php');
  include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'settings.inc.php');
  
  $images_path = '';
  $get_images = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'image ORDER BY id_product ASC;');
  $get_images_type = Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'image_type ORDER BY id_image_type ASC;');
  
  foreach ($get_images as $get_image) {
      $image = new Image($get_image['id_image']);
      $image_webp_url = _PS_ROOT_DIR_.'/img/p/'.$image->getExistingImgPath().".webp";
      $images_path .= $image_webp_url."\r\n";
      
      if (file_exists($images_path)) {
          unlink($images_path);
          echo 'deleted image: '.$images_path.'<br />';
      }
      
      foreach ($get_images_type as $get_image_type) {
          $image_jpg_url = _PS_ROOT_DIR_.'/img/p/'.$image->getExistingImgPath().'-'.$get_image_type['name'].".jpg";
          
          if (file_exists($image_jpg_url)) {
              unlink($image_jpg_url);
              echo 'deleted image: '.$image_jpg_url.'<br />';
          }
          
          $image_webp_url = _PS_ROOT_DIR_.'/img/p/'.$image->getExistingImgPath().'-'.$get_image_type['name'].".webp";
          
          if (file_exists($image_webp_url)) {
              unlink($image_webp_url);
              echo 'deleted image: '.$image_webp_url.'<br />';
          }
      } 
  }
  
  echo 'Done';
  
  
  

 

Then just write a script that regenerates the images. But I will not write here anymore.
It's laborious.

Edited by Guest (see edit history)
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...