How can I best generate/load a thumbnail [closed] - php

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)

Related

Best method to server-side img compress from full src img [closed]

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.

Show images and play videos without allowing copying, or downloading [closed]

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 5 years ago.
Improve this question
Is there any way to display images and / or videos on a website and not allow visitors to download or copy them?
I once saw a website where I tried to download an image, but then it was impossible to open it on my computer because the file type was not recognized on my computer!
Is there any way to encode the files, maybe?
Thank you all.
If you can show the images and videos in a browser, they will always find a way to copy these. You can't have the cake and eat it.
The only thing you can do is to make it harder for the newbie.

How chnage image size before uploaded on server [closed]

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 want to change image size before uploaded on server/mysql database, As its for member, so member can uploaded big images in size and i want to prevent and assign a new image size of their images.
I need it in PHP.
Thanks
Resizing an image in php without uploading first is not possible as php only runs on the server side. It can be done with js though, there are a lot of libraries that can help you out, like Jimp, Jcrop and Processing.js.
If you really want it in php than the image has to be uploaded first and than you will be able the resize the image with imagecopyresized function for example.
The php manual has an example here

Images should only load when scrolling down to reduce bandwidth [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 7 years ago.
Improve this question
well, i am reading out an image folder with lets say 300 images with php.
It runs fine.
To reduce bandwidth, i want to load the images only, if they are in the viewport.
If I'm not wrong you want your images to load when you scroll down the page. So, you need to use lazy loading in your application.
See this example
Let me know if you have any question.
So you are looking for an infinite scrolling, as far as I understand.
You have some plugins that may help you:
http://jscroll.com/
http://infinite-scroll.com

How can optimize images created in real time? [closed]

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
How can optimize images created in real time? I have a php file that creates chess diagrams with FEN in real time. I use ~12 of those chess diagrams on my main web page at http://communitychessclub.com/index.php
Is there a way I could pipe or tee the img url?
It seems that these image don't change on every request, so you should definitely cache them.
Make hash (sha1, md5) string from attributes for file name and save them as jpegs. On every page request check if file exist, if not, generate, cache and return it. It will be way faster.
To optimize more you could use ajax. Return page with placeholders for images, then load each image with ajax and replace placeholders.

Categories