A simple gallery example
In this typical gallery example, I’ll show how you load an image from an uploaded file, resize to two different sizes, and apply watermark to them.
First, load an image directly from an uploaded file, presented in an input file field named “pic”.
Then, resize the image to a decent size, so that you avoid too large images.
Crop a 300×300 rectangle from the middle, resize to 100×100, and save a thumb.
Sharpen the image up a bit, and apply watermark to the bottom-right corner of the image.
Show the image size and save the image.
That is all.
First, load an image directly from an uploaded file, presented in an input file field named “pic”.
- try
- {
- $image = WideImage::load('pic');
- }
- catch (Exception $e)
- {
- echo "Image isn't valid";
- }
- $image = $image->resize(1600, 1200);
- $image->crop('center', 'center', 300, 300)->
- resize(100, 100)->saveToFile('image-thumg.png');
- $logo = WideImage::load('logo.png');
- $large = $image->unsharp(80, 0.5, 3)->merge($logo, 'right', 'bottom');
- echo $large->getWidth() . 'x' . $large->getHeight();
- $large->saveToFile('image-large.png');
Nenhum comentário:
Postar um comentário
contribua com uma idéia, escreva aqui: