Image file permission - image resizer - php

PHP
mySQL
Hi, i am having an interesting problem.
I have a form in my cms that allows the admin to upload images to the server. The script resizes the images to a thumbnail (170px height)and a large image(600px height). The thumbnails are around 16000k in size and the large images are around 160,000k in size.
I do not set file permissions and just let it happen automatically.
When i go to the site i can see the thumbnails but i can't see the full size images and i have tracked the problem down to the file permissions. The thumbnails have rw-r-r permissions and the larger images have rw-- -- -- permissions. Ie the public does not have permission to view the large images. I save the large images with the name of the original and i save the thumbnails with _thumbnail appended to the end.
Why would the permissions of the large images be different when they are both uploaded and resized by the same script and when i do not set file permissions? Does the size have something to do with it? I only get this problem when uploading images to the production server, not when working on my local machine.
Thanks
Andrew

How are you resizing the images? Are you using an external program?
This is just a guess, but here goes
admin uploads image.jpg via your form
php script writes uploaded image.jpg to file system as rw- --- --- (600)
php script calls image resizer program to create image_thumbnail.jpg
image resizer writes image_thumbnail.jpg as rw- r-- r-- (644)
php script calls image resizer program to create resized image.jpg
image resizer overwrites image.jpg, but leaves permissions as rw- --- --- (600)
To test this theory, comment out the part where it resizes image.jpg to 600px, and then check the permissions of the originally uploaded image. If they are 600, then there's your problem.
Regardless though, a simple chmod will solve your problem.

I will suggest you to first look at your php.ini file
;Maximum allowed size for uploaded files.
upload_max_filesize = 10M
;Maximum size of POST data that PHP will accept.
post_max_size = 10M
The default settings would be 2M. You will need to change it like I mentioned here. If its still not working please get back.

Related

Why are my PNG images bigger in filesize than the source after upload to magento?

I recently discovered iloveimg.com as a way to genuinely compress my png images before I upload them to my store. However, I have problems uploading the png image as-is:
For example I uploaded this file which has 17.125 Bytes to a CMS Page via the insert image feature. After the successful upload, this file on the server has now 32.287 Bytes. At this point I did not even insert the image to the page, I just uploaded it. To my surprise it almost doubled the filesize. I linked to each file so maybe this helps identifying the issue.
Can anyone explain why this does happen? I suppose it has something to do with the Gd2.php file which unfortunately I cannot fully understand nur handle. I am using magento 1.9.3.4.

Dropzone.js / Laravel image upload to S3 failing on larger images 500 error

I have my Laravel site set up and have an image uploading test page.
I am using Dropzone and the AWS S3 package to handle my image uploads to my S3 Bucket.
Locally, using mamp, I can upload any image without any issues. However when pushing to both a shared hosting and also FortRabbit I get 500 / 503 errors when uploading an image over X mb.
An image 330kb uploads fine, but an image that is 1mb / 700kb etc will not work.
The images are a mixture of png and jpg and some work some don't. All I can put it down to is the smaller images are working fine and the ones from my DSLR are failing.
The phpinfo() shows:
Which to me looks fine?
I am really stuck on where to look to debug this one. Maxfilesize in dropzone is also set as 10mb.
Check other php.ini config values, particularly upload_max_filesize.

Apache can't display some images in same folder

I have more than 4500 images uploaded in the same folder. I'm uploading images with a php script. It was working fine but today i can't see images on web browser.
I can see a.jpg but i can't see b.jpg. All files have same size (3MB), same type (jpeg) and same access (644).
I tried to download the image to my disk with FTP. I can see on my mac. But i can't see on web browser.

how can i get the name of imagick temp file after imageresize

Using imagemagick, I need to resize images of multiple sizes (800px, 400px, 50px).
And I do not want to save these image locally because I need to upload the image to Amazon S3 anyways.
For example, after the following code
$im->resizeImage(0, 800, imagick::FILTER_LANCZOS, 1, FALSE);
$im->getImageFilename() still returns the original temp file uploaded prior to resizing. What I need is the temp file name & path after the resizing so that I can upload it straight to Amazon S3 without doing writeImage() locally. To save time and space.
Any suggestion?
There is no "temp file". ImageMagick does operations in memory. If you want the image to be written out to a file you need to call $im->writeImage.

Image gallery loading images from an external server

I am trying to make a php image gallery where the script has to the following things:
Connect to external server (http/ftp)
scan directory "highres"
load images from directory "lowres" with same image name.
save low-res images on local folder
Show low-res images in gallery
Download button for the high-res image
Can anyone point me into the right direction cause i dont know where to start.
Take a look at FTP with PHP and start with reading out the files in the Folder FTP Documentation
Then use ftp_get() to download the first Image and resize it with help of the GDlib, here is a tutorial for a thumbnailing function. Or download all images at once and resize them all at once.
Now you are at the last step just show your thumbnail and link to the high-res images.

Categories