Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

mail_open
Resizing images script
Sylvester Saldanha

Not so New
March 18, 2014 - 10:58 pm
Member Since: October 15, 2013
Forum Posts: 7
sp_UserOfflineSmall Offline

I have seen the video to resize the images. I have existing images which are hosted on the server. can this be all resized in one go using the script?

Avatar
Matthew Ogborne

Founder
March 18, 2014 - 11:11 pm
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Sylvester,

Yes if you use Magmi to import them all again.

However if you have loads and loads of images, it would be a better suggestion to resize the images from the servers commandline with an adapted script that recursively looks for the images as this would be much faster. You will need a PHP developer to do this for you.

It’s not impossible to do (as I did this for a project last year) and shouldn’t be expensive either. Freelancing sites such as oDesk or Elance would be suggested for this.

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

Sylvester Saldanha

Not so New
March 19, 2014 - 1:46 pm
Member Since: October 15, 2013
Forum Posts: 7
sp_UserOfflineSmall Offline

Hi Matt i have the code below to do this but i need a code to check if the image is less that 500 pixels before it resizes. Any chance you could help?

<?php
/*
smk_magento_resizer.php

Resizes Images for isolated/specific magento (admin) server

Created By: Samuel Maciel Sampaio (samukasmk@gmail.com) [20130828]

References where I got the core:
http://stackoverflow.com/questions/2474117/how-to-get-a-products-image-in-magento
http://stackoverflow.com/questions/10426210/how-to-get-product-image-in-magento

Special Thanks for stackoverflow users:
Suman-PHP4U (http://stackoverflow.com/users/795510/suman-php4u)
silvo (http://stackoverflow.com/users/295614/silvo)
Ricardo Martins (http://stackoverflow.com/users/529403/ricardo-martins)
Mitch Thompson (http://stackoverflow.com/users/1399382/mitch-thompson)
gowri (http://stackoverflow.com/users/430112/gowri)
alex (http://stackoverflow.com/users/297028/alex)
daveshaw (http://stackoverflow.com/users/383710/daveshaw)
Suma Gowda (http://stackoverflow.com/users/1284719/suma-gowda)
Vikrant 33 (http://stackoverflow.com/users/1379084/vikrant-33)
Andriy M (http://stackoverflow.com/users/297408/andriy-m)
Shiv Kumar (http://stackoverflow.com/users/1226172/shiv-kumar)

For execute in command line:
-> Put this script in your magento root path:
EG:
# cd /var/www/html/my_magento_folder
curl -O smk_magento_resizer.php

-> Running resize images creation
# curl -L http://my-magento.com/smk_magento_resizer.php

-> If you prefer, set this call in cron
# crontab -e
—-
# 5 * * * * curl -L http://my-magento.com/smk_magento_resizer.php
*/

ini_set(‘display_errors’,’on’);
require_once ‘app/Mage.php’;
Mage::app(‘default’);

$collection = Mage::getModel(‘catalog/product’)->getCollection()->addAttributeToSelect(‘*’);

echo "<pre>";
echo "<br>";

// echo "—";
// echo "\n";
// echo "\n\n";

foreach ($collection as $product) {

$_product = Mage::getModel(‘catalog/product’)->load($product->getId());

/* resize functions is used to resize image */

// echo product name
echo $_product->getId() . ‘ – (‘ . $_product->getName() . ‘)’ . ‘: ‘ . $_product->getProductUrl();
echo "<br>";
// echo "\n";

// main image of homepage/catalog
echo Mage::helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(312);
echo "<br>";
// echo "\n";

echo Mage::helper(‘catalog/image’)->init($_product, ‘thumbnail’)->resize(312);
echo "<br>";
// echo "\n";

// main image of product page
echo Mage::helper(‘catalog/image’)->init($_product, ‘image’)->resize(1000,1000);
echo "<br>";
// echo "\n";

// main small size image of product page
echo Mage::helper(‘catalog/image’)->init($_product, ‘image’)->resize(470,470);
echo "<br>";
// echo "\n";

// thumbnails images of product page
echo Mage::helper(‘catalog/image’)->init($_product, ‘thumbnail’)->resize(140,140);
echo "<br>";
// echo "\n";

// image of product in cart
echo Mage::helper(‘catalog/image’)->init($_product, ‘small_image’)->resize(88,77);
echo "<br>";
// echo "\n";

// thumbnails images of product cart
echo Mage::helper(‘catalog/image’)->init($_product, ‘thumbnail’)->resize(75);
echo "<br>";
// echo "\n";
}

echo "</pre>";
?>

Avatar
Matthew Ogborne

Founder
March 20, 2014 - 7:47 am
Member Since: July 18, 2013
Forum Posts: 4565
sp_UserOfflineSmall Offline

Hi Sylvester,

You’ll need to have an external developer check this for you, we’re tied up with recording tutorials at the moment.

Matt

"Selling an item online is easy, but making living from a business that sells online, well that’s something different entirely!"

Ultimo Magento Theme

 

Why Should You Join UnderstandingE?

 
  • Access to over 500 step-by-step video tutorials
  • +20 video courses available
  • Magento, M2E Pro, Magmi, eBay, Amazon & Design all covered
  • Everything is in 100% Plain English
  • Learn how to build your own multi-channel software for eBay & Amazon
  • Access to the community forums, meet fellow business owners like yourself

Join Now with 2 Clicks

 

Join now for less that £1 per day you can gain access to over 400 step-by-step video tutorials & learn how to build your very own multi-channel software.

 

Forum Timezone: Europe/London

Most Users Ever Online: 1012

Currently Online:
37 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

Jim @ Moogento: 688

Steve Froggatt: 514

Badeth - UE: 513

Jimbob: 453

Paul Cartwright: 414

Forum Stats:

Groups: 6

Forums: 37

Topics: 5221

Posts: 27485

Administrators: Matthew Ogborne: 4565, Dave Furness: 4606