Git Product home page Git Product logo

jssellars / php-resize-images-dynamically Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jaredblyth/php-resize-images-dynamically

0.0 0.0 0.0 144 KB

It is a good idea to upload your high resolution photos from your digital camera to the cloud for safekeeping, back-up and everywhere access. However, viewing these photos online usually means either downloading each high resolution original (which is a slow process), or viewing a thumbnail copy. Unfortunately, you usually need to pre-create the thumbnails yourself using software, and then upload them to the cloud. This script enables you to create a reduced and resized copy of your high resolution photos directly on the server and provide a new URL for the smaller copy to the webpage or device. Large photos do not need to be downloaded which prevents large amounts of data being transferred across the internet connection.

Home Page: http://jaredblyth.com/page.php?id=17

PHP 100.00%

php-resize-images-dynamically's Introduction

php-resize-images-dynamically

It is a good idea to upload your high resolution photos from your digital camera to the cloud for safekeeping, back-up and everywhere access. However, viewing these photos online usually means either downloading each high resolution original (which is a slow process), or viewing a thumbnail copy. Unfortunately, you usually need to pre-create the thumbnails yourself using software, and then upload them to the cloud. This script enables you to create a reduced and resized copy of your high resolution photos directly on the server and provide a new URL for the smaller copy to the webpage or device. Large photos do not need to be downloaded which prevents large amounts of data being transferred across the internet connection.

Because the thumbnails are created on the fly when they are needed, thumbnail copies do not need to be created and pre-stored on the server. In fact, this script allows you to create any sized thumbnail on the fly by providing a percentage parameter in the URL string.

This script works in PHP4 & PHP5 and creates a resized copy of an image identified using a URL string.

There a few PHP functions you can use to achieve this photo resizing function. I use "imagecopyresampled" as I find it scales well compared to the other functions.

Please note that this script is not designed to be inserted directly into HTML as an image. Rather this script creates a new URL to the smaller reduced copy of the photo on the server. This new URL can then be used as the source attribute for an HTML image.

Compare these two examples -

http://jaredblyth.com/photos/adelaide/DSC00110.JPG

http://jaredblyth.com/photos/photo.php?photo=adelaide/DSC00110.JPG&percent=0.1

The first link downloads the original high resolution photo from the server (2.24MB). The second link downloads a copy that is only 10% of the original size. No second copy exists, but instead is created on the server when requested. Try changing the percentage parameter in the URL to create a different sized thumbnail. These thumbnail copies are smaller file sizes than the original, which means that the bigger original photo and its 2.24MB don't need to be downloaded.

Included also are files to list the folders that are in a directory, and also display all the photos in each directory as thumbnails with links to open larger versions of the photos. One set of files uses plain HTML5 with the JQuery fancybox plug-in. The other set of files (portfolio) uses the Bootstrap theme Colorsy with a more colorful and responsive design. These files can be controlled via URL parameters to set the number of photos per page, the size of the thumbnails, and the size of the larger versions (as percentages of the original photos in the directory).

php-resize-images-dynamically's People

Contributors

jaredblyth avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.