Home »
Imported messages »
comp.lang.php »
Thumbnails with PHP
Re: Thumbnails with PHP [message #176116 is a reply to message #176115] |
Thu, 24 November 2011 10:06 ![Go to previous message Go to previous message](/forum/theme/default/images/up.png) ![Go to next message Go to previous message](/forum/theme/default/images/down.png) |
alvaro.NOSPAMTHANX
Messages: 277 Registered: September 2010
Karma:
|
Senior Member |
|
|
El 24/11/2011 10:51, Niels Lange escribió/wrote:
> at present I'm developing a website for a photographer. Currently I'm
> using PHPThumb (http://phpthumb.gxdlabs.com/) to create thumbnails
> resp. to trim the uploaded photos. The problem is that I have to
> define a fixed upload format. Therefore it's only possible to create
> horizontal images but no vertical images.
I've never used that library but here's the first example I could find
in their manual:
<?php
require_once 'path/to/ThumbLib.inc.php';
try
{
$thumb = PhpThumbFactory::create('/path/to/image.jpg');
}
catch (Exception $e)
{
// handle error here however you'd like
}
$thumb->resize(100, 100);
$thumb->show();
?>
https://github.com/masterexploder/PHPThumb/wiki/Basic-Usage
So it's pretty obvious that the resize() method accepts a bounding box
size when you call it. You don't have to define a fixed size as you
claim. The same seems to happen with the other methods.
> In detail my clients expectations are as follows:
>
> - If he uploads a horizontal image it'll get cropped to a certain
> size, e.g. 800p x 600 pixel.
> - If he uploads a vertical image the image will cropped with a height
> of 600 pixel, centered in a 800 pixel width frame. Than that frame
> should be filled black.
Do you mean that horizontal images are cropped and vertical images are
resized? From the name (there's no further documentation as far as I
see) it seems that the getCurrentDimensions() method returns the image
size. An image is horizontal if width/height is greater than 1. Use that
to write a conditional that calls either crop() or resize().
--
-- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
-- Mi sitio sobre programación web: http://borrame.com
-- Mi web de humor satinado: http://www.demogracia.com
--
|
|
|
Goto Forum:
Current Time: Sun Feb 16 20:00:45 GMT 2025
Total time taken to generate the page: 0.03890 seconds