Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 10 months ago.
Improve this question
I want to display a simple image gallery on a PHP webpage where the images are compressed; however, it allows for full res jpegs to be downloaded. And I'm just curious what method you would recommend for a project like this?
I'm thinking I store the full-res jpeg on my server and use server-side PHP imagecreatefromjpeg() and imagejpeg() to create a lower-res thumbnail of the image with an option to download? Or I suppose I could store lower res and high res jpegs both on the server and just echo them out but I would rather not store the lower res if possible.
Are there any other options for a project like this? And if imagejepg() is a good option, would someone direct me in how to use it?
Lower-rez images typically take much less disk space, much less, than hi-rez images. Disk space is extremely unlikely to be a limiting factor when you pre-create the smaller images.
And, resizing and decompressing on the fly in response to user requests eats server power. Store the low-rez images: think green.
For what it's worth, WordPress (40% of web servers on the net) resizes on upload and stores resized images, so that approach is proven effective.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 1 year ago.
This post was edited and submitted for review 1 year ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
my current project involves getting all uploaded images to the same size in the end.
Furthermore I would like to hear about your approaches on how to do the image manipulation.
What I want to do:
A user uploads an image with the size of 2560x1440.
Now I want to display the image with the size of 1280x720. Well that's the easy part. Every library can scale an image down like that.
But if a user uploads an image with like 500x2000 a rescale to 1280x720 will be very ugly.
My idea was to create a blank image with the size of 1280x720 and scale the incoming image down to a heigt of 720 and make the background in gray. If you can follow me so far, the new image will now be 1280x720 but on the side it's filled gray with the original image in the center.
Would you do this the same way? Is there a library out there, that is capable of this?
Thank ahead
DaNeubi
Sounds like a reasonable approach. I'd look at ImageMagick for which there is a PHP extension. You'll need to write the logic to determine the image rescaling and background sizing.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 6 years ago.
Improve this question
I've been reading about resizing images on the fly using some php scripts with URL rewriting (/img/500x500/image-name.jpg), but a lot of people say it's a bad practice as it's a RAM and CPU consuming (1Mb image uses about 3Mb of RAM). So I thought I would just generate these images once and then save them in a cache folder, that way I can keep the original img and also the resized ones in this folder.
I'm currently saving 3 different sizes in the server when the image is being uploaded (100x100, 200x200, 500x500). Few time ago I used to display some images in 500x500, but now I have changed a little bit the design to display these images in only 300x300, So I'm now stuck with large images which could slow a little bit the page load!
So what I'm thinking to do is to save the original image (1500x1500), and when it's being viewed for the first time, i'll generate the appropriate thumbnails and save them in a folder on the server. That way, if I ever change the design again, I can simply delete the image cache folder to create the new thumbnails with the new sizes...
I still don't have any codes as the website is still being developed and I'm just trying to anticipate these facts. it's an ecommerce website
Do you think this is a wise way to deal with images??
I'm using php7, nginx, laravel 5 and also a CDN service (maxCDN)
Thanks in advance
I do this for thumbnails... pretty easy with Intervention image library... I mean, simple... http://image.intervention.io/
// open an image file
$img = Image::make('public/foo.jpg');
// now you are able to resize the instance
$img->resize(320, 240);
// finally we save the image as a new file
$img->save('public/bar.jpg');
That's it... and yes, resizing on the fly is a bad idea...
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I'm building a iPhone Application which displays some photos. First in a UICollectionView as a thumbnail then bigger in fullscreen.
For better loading behavior I would like to load smaller images first for the thumbnail part. Now: Should I do this via PHP and resize the existing big image or should I save a second image on the server XXX_thumbnail.png and load this one?
Thanks for your tip.
Chris
Resizing an image can be quite an intensive process for the server, especially with larger images. Imagine if 1000 users hit it at the same time. You absolutely should only do this once per image, and save it for later requests. Whether you pre-render all thumbnails or not is another matter, but executing a file_exists is pretty cheap. You can just render them once, at the time they are requested. All depends how you want to access them (e.g. through a script or just the thumbnail url directly)
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
I'm generating a pdf for every page using FPDF. Its working properly. But the main problem is with the file size. Some files have a size of more than 2Mb. I want to limit the size. How can I limit the size within 300 kb? Any help would be appreciated.
Typically PDFs are large because they contain large images or because they contain large fonts.
So the solution is typically to reduce the resolution of the images and to avoid the fonts getting embedded.
If FPDF will allow you to do this then this will likely solve your problem.
If not then you will need to post-process your PDF using another library to unembed the fonts and resample the images.
ABCpdf will do this using the ReduceSize operation. No doubt other libraries will allow something similar.
I work on the ABCpdf .NET software component so my replies may feature concepts based around ABCpdf. It's just what I know. :-)
The best way is to compress pdf file is that first you generate the pdf and then use any tool to compress the pdf file. As far as my experience is concerned, there is no other way to compress pdf file.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 years ago.
Improve this question
Please, any ideas on how to extract image from pdf in php?
Take a look at pdfimages. Here is the description from the page:
Pdfimages saves images from a Portable
Document Format (PDF) file as
Portable Pixmap (PPM), Portable Bitmap
(PBM), or JPEG files.
Pdfimages reads the PDF file, scans
one or more pages, PDF-file, and
writes one PPM, PBM, or JPEG file for
each image, image-root-nnn.xxx,
where nnn is the image number and
xxx is the image type (.ppm, .pbm,
.jpg).
NB: pdfimages extracts the raw image
data from the PDF file, without
performing any additional
transforms. Any rotation, clipping,
color inversion, etc. done by the PDF
content stream is ignored.
I believe you can use imagemagic as well. You can send it command line arguments and snap a picture given the coordinates you can provide. You will need to install some rpms etc.
Check out PDFLib. Their TET product does just that. You can get the images and text out... Only thing it doesn't cover is vector images.
If you have an existing PDF File I guess it's pretty impossible to extract an image from there using PHP, maybe you'll have better luck with C: you need to disassemble the binary file, decode/decompress/decompile it and find where the image is stored, then copy it.
It's easier if you just copy'n'paste it.