Jump to content

PS resize all images uploaded by customers. How do I deactivate it?


Recommended Posts

Hi,

I found that PS resize pictures which uploaded by customers. For examples it can be picture for T-shirt printing.

I can't find reason why need resizing because printshops need original files w/o resizing or edition in term of quality printing.

I am need even a sets of image files packed into zip or rar archive. It is conveniently for my customers.

1) Can I disable fie resizing?
2) How do I ad additional file extensions for customer uploadable files?
3) Can I disable file preveiw in the admin/order details?

thanks!

Link to comment
Share on other sites

I saw this in the products.php
their is a re-size original
and a re-size small

you could add an option to check for isPicture($file['tmp_Name'])
if that fails then you could copy ormove that file where ever u like.

I'll post morein a sec i got a phone call

Link to comment
Share on other sites

I finally got off the phone.

Ok you want the option to add other files like zip files and rar or psd

The software uses a re-sizer to modify images that are uploaded.
One is saved as a XXXXXX_small and the other is XXXXXXXX
the one with out the _small tag is of normal size (not re-sized, i believe)

in the products.php file function uploadimage()
There is a function that checks to see if the object is an image.
This function is CheckImage()
This function is located in the images-inc.php
This is a overloaded functions so check your parameters to make sure your on the right one.

The function first checks to see if the file is of the right size
It then checks to see if the file is an image using IsPicture()
the IsPicture() is also located in the images-inc.php
If you wish to add file types you can add them to the IsPicture function
In that function you will find an array list with the valid file types.

Once thing you have to look out for is make sure you don't try to re-size a psd file
it might work since it can re-size png files but they are saved without layers.

Now if you wanted to add a zip file or other file extension you can create a new function
that validates your other file types.

So If a file fails its IsPicture but pass the IsOther. Then you can do what you like with the file.
Basically in the products.php uploadimage() if check checkimage() = fail then checkother()
if cehckother() = true then process the file just like the image but don't re-size it. You might have to do your own path combines so that you don't lose your file extension.

I plan on doing this my self. When I get some free time I'll post what I have.

Note you will also have to modify your back end so that you can download the file from a link and not try to display it.

Link to comment
Share on other sites

I guess it is better to exclude both image resizing for preview as well as for file saving on site.

I uploaded 1Mb file. When I downloaded it back from Back office it size was 700 Kb. Size of picture in pixel was same. PS compressed files. It is unacceptable, because for printing I need original files.

Preview image is't need also. It is not informative. Just feature. Small image or .ico depend of file type or even one for all types file for link to saved file in Back office will be enough.

I couldn't find where is file limitation of 1,3 Mb. will do later.

I will try to make changes tomorrow. Unfortunately I am not so friendly with php coding.

Link to comment
Share on other sites

I had some trouble with the file limitation myself.
I was also unable to locate where the value was coming from.
I just over wrote my value in the checkimage() function
The first condition in that function checks to see if the file is larger than $MaxFileSize
I replaced the $MaxFileSize with 38000000 or something like that, this solved the file size issue.

The checkimage() is located in the image-inc.php

Link to comment
Share on other sites

Now customers can make upload of big files. What I did:

1) changed php.ini

upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 300



I guess it should be in .httaccess, however I work on local server.

2) changed admin/tabs/AdminAttachments.php - increase limit of managed files.

//from
protected $maxFileSize  = 2000000;
//to
protected $maxFileSize  = 20000000;



3) changed product.php - added call for new function

//from
elseif (!imageResize($tmpName, _PS_PROD_PIC_DIR_.$fileName))
//to
elseif (!imageNoResize($tmpName, _PS_PROD_PIC_DIR_.$fileName))



4) added new function imageNoResize() to image.inc.php before imageResize()

/**
 * No resize, no cut or no optimize image, just copy one image to another one. used for original image.
 * @return boolean Operation result
 */
function imageNoResize($sourceFile, $destFile, $destWidth = NULL, $destHeight = NULL, $fileType = 'jpg')
{
   list($sourceWidth, $sourceHeight, $type, $attr) = getimagesize($sourceFile);
   if (!$sourceWidth)
       return false;

   $sourceImage = createSrcImage($type, $sourceFile);
   $destImage = $sourceImage;

   return (returnDestImage($fileType, $destImage, $destFile));
}



5) edited image.inc.php function returnDestImage() - improve picture quality.

//from
$flag = imagejpeg($ressource, $filename, 90);
//to
$flag = imagejpeg($ressource, $filename, 95);



Finally. Customer can upload big images up to 20M and even admin can increase limit. But the problem with ZIP or other file types is still remining.
Internet Printshop needs only unresized and unchaged files only - because of quality issue. We print files up to 1Gb. However PHP functions used for image upload make resizing and optimizations.
Quality and eligibility of uploaded images can check only print-worker, not admin or operator of Prestashop. So image preview is not need. Admin is needed link for file download or deleting.

Task list:

1) BO: Admin manage list of allowed files for upload (e.g. jpg, tif, zip, rar).
2) BO: Admin manage max file size.
3) FO: Customer upload allowed files only.
3.a) PS copy files from customer computer to server w/o changes or treatment.
3.B) PS create link for cart, BO/vieworder, FO/blockmyaccount/history.

I am not a php-programmer and it is not a trivial task for me. But I will try. If anyone can help - you are welcome.

Link to comment
Share on other sites

  • 3 months later...
  • 2 months later...

I found this really helpful and it worked a treat - thanks

My only issue was that I do not have access to the php.ini file and my website host would only allow uploads of 2MB. I got round this by creating the .htaccess file outlined in this post and placing the file in my root directory.

Link to comment
Share on other sites

  • 1 month later...
Now customers can make upload of big files. What I did:

1) changed php.ini

upload_max_filesize = 20M
post_max_size = 20M
max_execution_time = 300



I guess it should be in .httaccess, however I work on local server.

2) changed admin/tabs/AdminAttachments.php - increase limit of managed files.

//from
protected $maxFileSize  = 2000000;
//to
protected $maxFileSize  = 20000000;



3) changed product.php - added call for new function

//from
elseif (!imageResize($tmpName, _PS_PROD_PIC_DIR_.$fileName))
//to
elseif (!imageNoResize($tmpName, _PS_PROD_PIC_DIR_.$fileName))



4) added new function imageNoResize() to image.inc.php before imageResize()

/**
 * No resize, no cut or no optimize image, just copy one image to another one. used for original image.
 * @return boolean Operation result
 */
function imageNoResize($sourceFile, $destFile, $destWidth = NULL, $destHeight = NULL, $fileType = 'jpg')
{
   list($sourceWidth, $sourceHeight, $type, $attr) = getimagesize($sourceFile);
   if (!$sourceWidth)
       return false;

   $sourceImage = createSrcImage($type, $sourceFile);
   $destImage = $sourceImage;

   return (returnDestImage($fileType, $destImage, $destFile));
}



5) edited image.inc.php function returnDestImage() - improve picture quality.

//from
$flag = imagejpeg($ressource, $filename, 90);
//to
$flag = imagejpeg($ressource, $filename, 95);



Finally. Customer can upload big images up to 20M and even admin can increase limit. But the problem with ZIP or other file types is still remining.
Internet Printshop needs only unresized and unchaged files only - because of quality issue. We print files up to 1Gb. However PHP functions used for image upload make resizing and optimizations.
Quality and eligibility of uploaded images can check only print-worker, not admin or operator of Prestashop. So image preview is not need. Admin is needed link for file download or deleting.

Task list:

1) BO: Admin manage list of allowed files for upload (e.g. jpg, tif, zip, rar).
2) BO: Admin manage max file size.
3) FO: Customer upload allowed files only.
3.a) PS copy files from customer computer to server w/o changes or treatment.
3.B) PS create link for cart, BO/vieworder, FO/blockmyaccount/history.

I am not a php-programmer and it is not a trivial task for me. But I will try. If anyone can help - you are welcome.




Hi, I followed all the steps but no work!! all the images are compressed my shop is www.sttikup.com
http://www.sttikup.com/artistas/11-wild-sea.html

I hope you can help me about it

I don't Know what can i do!
thanks in advance
Link to comment
Share on other sites

  • 2 months later...
I can't find the php.ini file


if you work online it is on hosters server side.

try to put into .htaccess folowing:

# Max size upload file
php_value upload_max_filesize 100M
php_value post_max_size 100M
php_value max_execution_time 300
php_value max_input_time 300

probably it will help.
Link to comment
Share on other sites

there doesn't seem to be any thing in my htaccess file....should there be?
when I do what you suggest I get the following Error
500 - Internal Server Error
This is a temporary server error.
Please try to reload the webpage later.

If you are the webmaster of this site please log in to Cpanel and check the Error Logs. You will find the exact reason for this error there.

Common reasons for this error are:
Incorrect file/directory permissions: Above 755. In order files to be processed by the webserver, their permissions have to be equal or below 755. You can update file permissions with a FTP client or through cPanel's File Manager.
Incorrect Apache directives inside .htaccess file. Make sure you have not specified unsupported directives inside the local .htaccess file. Such include PHP settings and Apache module settings.

Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...
  • 1 month later...
  • 3 months later...
×
×
  • Create New...