Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

NetTuts.com:
Resize and Manipulate Images in PHP (With Examples)
Sep 14, 2018 @ 15:38:31

The NetTuts.com site has continued their series covering the use of the GD functionality in PHP to manipulate images with a new tutorial posted today. In this second part of the series they focus in on resizing and manipulating images.

In my previous tutorial, we discussed basic image manipulation using the PHP GD library. In that tutorial, I gave a brief introduction to the library and showed you how to load images from a file or create them from scratch in PHP. After that, we learned how to crop, rotate, scale and flip an image using GD. I covered the imagefilter() function to apply different filters to image resources loaded in the script. I also mentioned some useful functions in GD like imagesx() and imagesy() to get the width and height of the loaded image.

By the end of my last GD tutorial, you learned how to use the library to automate basic tasks like resizing all images in a directory or applying filters like grayscale on them before saving the final result. [...] In this tutorial, we will learn about many more useful functions in GD and how they can be used to automate more of our image manipulation tasks.

They start by looking at the imageconvolution function and the use of a "convolution matrix" and how it can be useful to blur, sharpen, emboss, or detect edges on an image. It then covers the functions used to copy images and alter the end result by changing contrast or converting to grayscale. Finally, the author shows how to use the GD functionality to dynamically add a watermark to the image and output the result to a new file.

tagged: gd graphics tutorial resize manipulate image

Link: https://code.tutsplus.com/tutorials/php-gd-image-manipulation-beyond-the-basics--cms-31766

SitePoint PHP Blog:
Improving Performance Perception: On-Demand Image Resizing
Jul 03, 2018 @ 17:08:20

The SitePoint PHP blog has continued their series covering the creation of an online image gallery application. The series has included several tutorials covering performance and optimization improvements. In this latest article they continue that trend focusing on optimizing the resizing of the images.

We’ve been building a sample application — a multi-image gallery blog — for performance benchmarking and optimizations. At this point, our application serves the same image regardless of the resolution and screen size it’s being served in. In this image resizing tutorial, we’ll modify it to serve a resized version depending on display size.

They start by listing out the requirements for the improvement: make all images responsive and the addition of the code to generate the resized image. Next it discusses the state of responsive images on the web and shows the first additions to the templates for the "srcset" value. They create some helper methods in Twig to get the image URL and "srcset" value. Next up, the tutorial helps you install the league/glide package and use it to create a script to manually "serve" the resized image information back to the user.

tagged: performance image resize tutorial series ondemand

Link: https://www.sitepoint.com/improving-performance-perception-on-demand-image-resizing/

StartTutorial.com:
Dynamic image resizing via URI with Glide and Slim
Feb 02, 2017 @ 18:45:58

The Star Tutorial site has a new article posted showing you how to create a system based on Glide and the Slim framework to dynamically resize images with a few simple URLs.

If you have ever used WordPress.com backend. You will notice its image resizing works by appending a dimension string at the end of the URL.

In this tutorial, we will show you how to do that for your own project. At the end of this tutorial, you will have an image resizing server that is able to give you specific dimension upon request.

The tutorial starts with a basic introduction to the Glide image manipulation tool and how to get a Slim installation up and running. They then help you install the league/glide-slim package to help link the two. With those in place, they show you how to build out the resizing code using the ServerFactory handling to grab the image, passing in the URL parameters to tell Glide how to manipulate the image.

tagged: tutorial dynamic image resize uri glide slim

Link: https://www.startutorial.com/articles/view/dynamic-image-resizing-via-uri-with-glide-and-slim

CodeGeekz:
Cropping Images in PHP Based on their Entropy
Feb 03, 2014 @ 17:25:42

On the CodeGeekz site there's a new post showing you how to use the Imagick extension and a custom library to crop images based on their entropy (keeping the "busiest" part of the image).

The need to resize and crop images in order to create thumbs, is a very common scenario for most websites. For example a blog like this one uses images in the content of the posts, images which at some point are used to create a thumb for the homepage. In most cases, the thumb’s dimensions are not dynamic but are static throughout the website in order to better fit the template. This however creates a major problem when we try to automatically resize and crop our images in the desired dimensions.

He starts with an example of the normal kind of cropping based on a given height and width. He points out an issue with "smart cropping" and resizing the image with the cropping is done. Instead, he's made use of Imagick in his library to produce a better cropped image based on the parts of the image with the most entropy.

tagged: crop image entropy busy resize smart tutorial

Link: http://codegeekz.com/cropping-images-entrop/

PHPMaster.com:
Crop and Resize Images with ImageMagick
May 02, 2013 @ 17:14:51

PHPMaster.com has a new tutorial posted showing you how to crop and resize images with the help of the ImageMagick functionality that can be added to PHP (via this extension).

If your website allows users to upload photos, image cropping/resizing functionality certainly comes in handy. But users might not have access to image manipulation tools like Photoshop, so by providing a cropping/resizing feature you can allow users to upload photos from any device (e.g. tablets or phones) without them having to worry about the the final size. Furthermore, you can create different versions of the same image and also allow users to crop specific portions of uploaded picture. In this article I’ll show you how to create an image cropping tool with the help of the ImageMagick PHP extension.

The post shows the use of the "cropimage" function to trim down an image from its original size and "thumbnailImage" to shrink down the image to make a thumbnail. Also included is the code (both the PHP and the HTML form) to handle file uploads and automatically create a thumbnail image. It outputs the image to the browser and asks the user to select the portion they want thumbnailed (with this jQuery plugin helping).

tagged: crop image imagemagick tutorial resize extension

Link: http://phpmaster.com/crop-and-resize-images-with-imagemagick

NETTUTS.com:
Image Resizing Made Easy with PHP
Mar 19, 2010 @ 13:47:48

New from NETTUTS.com there's a recent tutorial showing you how to use the GD graphics library (bundled with PHP) to resize images on the fly.

Ever wanted an all purpose, easy to use method of resizing your images in PHP? Well that’s what PHP classes are for – reusable pieces of functionality that we call to do the dirty work behind the scenes. We’re going to learn how to create our own class that will be well constructed, as well as expandable. Resizing should be easy.

The simple eleven-step process (don't worry, it sounds worse than it is) has you go from a basic image and, with the help of a custom PHP class, create a resized image based on a type such as "landscape", "auto" or "exact". Full code is included for you to cut and paste or you can download the source and have the full code ready and waiting.

tagged: image resize tutorial gd graphic library

Link:

Kae Verens' Blog:
pre-parsing HTML for incorrectly-sized images
Jul 29, 2008 @ 17:03:55

Kae Verens has a recent blog post that looks at a method for helping to protect users from themselves when working with images - a method for handling ones incorrectly sized.

Every now and then, I get a call from a client who is puzzled why their site is running slow. I would look at their page and see an innocuous image inserted into a paragraph. When I examine the image, though, I see that the client has artificially resized the image using HTML. One recent example showed on-screen as a 300px-wide image. When I examined it, it was actually 3000px wide (approx).

The script looks through some HTML markup and, based on the sizes in the image tags, resizes the images appropriately. An example and the source are provided.

tagged: html image size height width parse resize

Link:

Mikko Koppanen's Blog:
Seam carving
Feb 13, 2008 @ 23:10:00

Mikko Koppanen has posted another quick hit ImageMagick hint to his blog - this time it deal with "seam carving", a process for cropping and resampling of an image to make a different composite picture.

Today I was reading trough the ImageMagick ChangeLog and noticed an interesting entry. "Add support for liquid rescaling". I rushed to check the MagickWand API docs and there it was: MagickLiquidRescaleImage! After about ten minutes of hacking the Imagick support was done. Needless to say; I was excited

You'll need to have the libqr library compiled into the ImageMagick installation, but the actual use of the functionality is simple - about three or four lines do the work for you. He includes the original image and the result from his test (as well as another example of the same result image scaled down automatically.

tagged: imagemagick seam carving image resize libqr

Link:

The Bakery:
Image Resize Helper
Feb 21, 2007 @ 15:48:00

The Bakery has a new helper posted today for those working with images in their applications that need to resize and cache them easily.

This helper resizes an image on the fly and places it in an image cache directory for later use. Make sure your imagecache directory is writable. Future editions could include a cropping function.

The full code of the class is provided in both a cut and paste-able format and for download. There's an example of the sample usage included as well.

tagged: image resize helper cakephpframework download crop image resize helper cakephpframework download crop

Link:

The Bakery:
Image Resize Helper
Feb 21, 2007 @ 15:48:00

The Bakery has a new helper posted today for those working with images in their applications that need to resize and cache them easily.

This helper resizes an image on the fly and places it in an image cache directory for later use. Make sure your imagecache directory is writable. Future editions could include a cropping function.

The full code of the class is provided in both a cut and paste-able format and for download. There's an example of the sample usage included as well.

tagged: image resize helper cakephpframework download crop image resize helper cakephpframework download crop

Link:


Trending Topics: