Jump to content

krodelabestiole

Members
  • Posts

    12
  • Joined

  • Last visited

Everything posted by krodelabestiole

  1. hello,I've just created a module that could be useful to people getting bored with the way PrestaShop handles pictures and thumbnails.It helps to generate images with no plain background, no modification to aspect ratio, etc.. I think it makes more sense to have image generation depending on themes than on settings in PrestaShop's administration panel.Images are generated seamlessly the first time someone visits the page where they are displayed and then cached for quicker view.For now it only handles product pictures, I might extend the script to other types of pictures if needed.The only thing to do is to install the module, then modify the img src tag in the theme templates to suit your need.https://github.com/crachecode/prestajine prestajine_2.0.0.zip
  2. HelloJe viens de développer un module qui permet de gérer la création des vignettes et des images, en passant outre le générateur natif, et donc sans générer de bordures blanches ou sans modifier le rapport d'aspect.Les images sont appelées directement depuis les templates du thème. Elles sont générées à la bonne taille lors de la première visite de la page et mises en cache pour un affichage rapide par la suite.https://github.com/crachecode/prestajineJ'ai créé ce module parce que le générateur de PrestaShop ne me semble pas faire de sens du tout. Les tailles des images devraient dépendre directement du thème, et il ne devrait pas exister d'images à bord blanc ou à l'aspect déformé. prestajine_2.0.0.zip
  3. hello im developping a module that uses overrides and stuffs i've disabled every cache functionalities available from the backoffice but i still have to manually delete /cache/class_index.php for everysingle change i make ! is there a way to disable the regeneration of this file ? thx
  4. You have to replace this : function imageResize($sourceFile, $destFile, $destWidth = NULL, $destHeight = NULL, $fileType = 'jpg') { list($sourceWidth, $sourceHeight, $type, $attr) = getimagesize($sourceFile); if (!$sourceWidth) return false; if ($destWidth == NULL) $destWidth = $sourceWidth; if ($destHeight == NULL) $destHeight = $sourceHeight; $sourceImage = createSrcImage($type, $sourceFile); $widthDiff = $destWidth / $sourceWidth; $heightDiff = $destHeight / $sourceHeight; if ($widthDiff > 1 AND $heightDiff > 1) { $nextWidth = $sourceWidth; $nextHeight = $sourceHeight; } else { if (intval(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 2 OR (intval(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 0 AND $widthDiff > $heightDiff)) { $nextHeight = $destHeight; $nextWidth = intval(($sourceWidth * $nextHeight) / $sourceHeight); $destWidth = (intval(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 0 ? $destWidth : $nextWidth); } else { $nextWidth = $destWidth; $nextHeight = intval($sourceHeight * $destWidth / $sourceWidth); $destHeight = (intval(Configuration::get('PS_IMAGE_GENERATION_METHOD')) == 0 ? $destHeight : $nextHeight); } } $borderWidth = intval(($destWidth - $nextWidth) / 2); $borderHeight = intval(($destHeight - $nextHeight) / 2); $destImage = imagecreatetruecolor($destWidth, $destHeight); $white = imagecolorallocate($destImage, 255, 255, 255); imagefill($destImage, 0, 0, $white); imagecopyresampled($destImage, $sourceImage, $borderWidth, $borderHeight, 0, 0, $nextWidth, $nextHeight, $sourceWidth, $sourceHeight); imagecolortransparent($destImage, $white); return (returnDestImage($fileType, $destImage, $destFile)); } which stand from line 116 to line 161 on my version of prestashop with this : function imageResize($sourceFile, $destFile, $destWidth = NULL, $destHeight = NULL, $fileType = 'jpg') { list($sourceWidth, $sourceHeight, $type, $attr) = getimagesize($sourceFile); if (!$sourceWidth) return false; if ($destWidth == NULL) $destWidth = $sourceWidth; if ($destHeight == NULL) $destHeight = $sourceHeight; require_once '../phpthumb/ThumbLib.inc.php'; $thumb = PhpThumbFactory::create($sourceFile); if ($destWidth > 300 || $destHeight > 300) { // if not a thumbnail then not square $thumb->resize($destWidth, $destHeight); } else { $thumb->adaptiveResize($destWidth, $destHeight); } return $thumb->save($destFile); } You can as well comment the first code by adding /* at first and */ after the end of the function then paste the second code underneath. I don't know why this whole code is on the same line on your quote : // if not a thumbnail then not square $thumb->resize($destWidth, $destHeight); } else { $thumb->adaptiveResize($destWidth, $destHeight); } return $thumb->save($destFile);} but it won't work this way cause everything is commented (// means the next code on the line won't be executed in PHP)
  5. more likely this kind of scripts http://www.hotscripts.com/blog/javascript-image-cropping-scripts/ http://deepliquid.com/projects/Jcrop/demos.php?demo=thumbnail seems to me it means a lot of work to implement
  6. je pense que l'ajout d'un fond uni est une très mauvaise idée ça rend les fichiers plus lourds et c'est moins souple graphiquement voir moche du coup j'ai un peu modifié images.inc.php pour qu'il puisse gérer un redimensionnement plus évolué des images en utilisant php thumb http://github.com/masterexploder/PHPThumb/wiki/Basic-Usage les miniatures (jusqu'à 300px) sont recadrées dans l'espace de la photo, pas d'espace mort les images pleines sont simplement rétrécies pour tenir dans la largeur ou dans la hauteur maximale spécifiée en back office évidemment on conserve toujours le rapport de l'aspect du contenu il faut télécharger phpthumb et l'extraire dans un dossier [prestashop root]/phpthumb/ qu'on crée ensuite il faut éditer [prestashop root]/images.inc.php remplacer (commenter) la fonction imageResize avec celle-ci : function imageResize($sourceFile, $destFile, $destWidth = NULL, $destHeight = NULL, $fileType = 'jpg') { list($sourceWidth, $sourceHeight, $type, $attr) = getimagesize($sourceFile); if (!$sourceWidth) return false; if ($destWidth == NULL) $destWidth = $sourceWidth; if ($destHeight == NULL) $destHeight = $sourceHeight; require_once '../phpthumb/ThumbLib.inc.php'; $thumb = PhpThumbFactory::create($sourceFile); if ($destWidth > 300 || $destHeight > 300) { // if not a thumbnail $thumb->resize($destWidth, $destHeight); // simple resize } else { $thumb->adaptiveResize($destWidth, $destHeight); // strict resize } return $thumb->save($destFile); } et voilà ! (plus qu'à régénérer les miniature en backoffice) c'est un hack un peu rapide mais ça a l'air de très bien marcher et ça fonctionne aussi avec les gif et les png en conservant les transparences !
  7. other good news is that it also works with gif and png, KEEPING TRANSPARENCIES :]
  8. yep sure i saw that first post is a workaround to this problem and it works quite fine : images up to 300px (usually thumbs) are both resized and cropped (adaptive resize) so that they fit exactly to their space, keeping aspect ratio. greater images (large pictures and thickboxes) are just uniformly resized to the max width OR max height specified in back office therefore the remaining issue with this mod is that when you upload an image smaller than 300px (of course you can adjust that number in the code) it will have to fit exactly in both width and heigth, what may crop it a bit, even on full views. the best way to deal with that would be to implement phpthumb in ps next versions and to add this strict/max option for each format in backoffice (i haven't mod this as it would ask to modify many other files and a bit of the database structure)
  9. hi i mostly agree sure the more options you have the best it is (when you can hide these options to keep it simpler to users) the point is i install and cusomize this interface for clients or friends who rarely know how to use photoshop, compress jpeg and so on... not all pay professionnal photographers / webmasters at this end i guess on this purpose automation stays the best solution, and it should be much better managed than it is now with these ugly borders phpthumb seems to me a nicer way to do this but i still miss some arguments in the fonction call to be the best. especially : are the size arguments strict or max (an info we would have to specify in the image settings for each small, medium, large, thickbox...) i hope some prestashop [spam-filter] will read about this
  10. i think adding this plain background to images is a really bad idea... to say it simply it makes image files heavier and it's ugly so i've just modified a bit images.inc.php so that it manage adaptive resize to thumbnails using php thumb as there : http://github.com/masterexploder/PHPThumb/wiki/Basic-Usage (scare thumbnails are filled with the photography, no dead spaces) so you have to download phpthumb and place it in a folder [prestashop root]/phpthumb/ you create then edit [prestashop root]/images.inc.php replace (comment) imageResize function with this one function imageResize($sourceFile, $destFile, $destWidth = NULL, $destHeight = NULL, $fileType = 'jpg') { list($sourceWidth, $sourceHeight, $type, $attr) = getimagesize($sourceFile); if (!$sourceWidth) return false; if ($destWidth == NULL) $destWidth = $sourceWidth; if ($destHeight == NULL) $destHeight = $sourceHeight; require_once '../phpthumb/ThumbLib.inc.php'; $thumb = PhpThumbFactory::create($sourceFile); if ($destWidth > 300 || $destHeight > 300) { // if not a thumbnail then not square $thumb->resize($destWidth, $destHeight); } else { $thumb->adaptiveResize($destWidth, $destHeight); } return $thumb->save($destFile); } here you are ! might be a bit dirty quick job : if the original picture is less than 300px high or wide then the main picture in front will be square cropped ... is there another way to know if the image is a thumnail or a full picture ? any else it should work fine
×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More