Skip to content

Commit

Permalink
Updated README.md with changes en v2.
Browse files Browse the repository at this point in the history
Also corrected some typos.
  • Loading branch information
carlosafonso committed Mar 29, 2015
1 parent e1ed9f4 commit 1feda01
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@ thumbnailr
Thumbnailr is a PHP library for dynamically generating image thumbnails in either PNG or JPEG format.

##Installation
###Installing via Composer
Since v1.1.0 Thumbnailr is available via Composer. Add a reference to Thumbnailr in your `composer.json` file;
Thumbnailr is available via Composer. Add a reference to Thumbnailr in your `composer.json` file;

```json
{
"require": {
"carlosafonso/thumbnailr": "1.1.0"
"carlosafonso/thumbnailr": "2.*"
}
}
```
Expand All @@ -31,50 +30,50 @@ $width = 200;
$height = 100;

// instantiate the library
$thumbnailr = new Thumbnailr($img);
$thumbnailr = new \Thumbnailr\Thumbnailr($img);

/*
* Generating the thumbnail
*/
// this will not keep the aspect ratio (both calls are equivalent)
$thumbnailr->build_thumbnail($width, $height);
$thumbnailr->build_thumbnail($width, $height, THUMBNAILR_SIZE_FIXED);
$thumbnailr->buildThumbnail($width, $height);
$thumbnailr->buildThumbnail($width, $height, self::SIZE_FIXED);

// keep the aspect ratio and fit the LONGEST side inside the thumbnail,
// (actual size will be smaller than specified)
$thumbnailr->build_thumbnail($width, $height, THUMBNAILR_SIZE_FIT_LONGEST);
$thumbnailr->buildThumbnail($width, $height, self::SIZE_FIT_LONGEST);

// keep the aspect ratio and fit the SHORTEST side inside the thumbnail size,
// (actual size will be larger than specified)
$thumbnailr->build_thumbnail($width, $height, THUMBNAILR_SIZE_FIT_SHORTEST);
$thumbnailr->buildThumbnail($width, $height, self::SIZE_FIT_SHORTEST);

/*
* Saving the thumbnail
*/
// save to a PNG file, apply standard compression
$thumbnailr->to_png_file('thumbnail.png');
$thumbnailr->toPngFile('thumbnail.png');

// same as above specifying a compression level (higher level means smaller file size)
$thumbnailr->to_png_file('thumbnail.png', 7);
$thumbnailr->toPngFile('thumbnail.png', 7);

// get the thumbnail as raw binary data
$raw_png = $thumbnailr->to_png_file(NULL);
$raw_png = $thumbnailr->toPngFile(NULL);

// get the PNG thumbnail as a base 64 string, apply standard compression
$png_b64 = $thumbnailr->to_png_base_64();
$png_b64 = $thumbnailr->toPngBase64();

// same as above specifying a compression level
$png_b64 = $thumbnailr->to_png_base_64(4);
$png_b64 = $thumbnailr->toPngBase64(4);

// save to a JPEG file, use standard quality
$thumbnailr->to_jpeg_file('thumbnail.png');
$thumbnailr->toJpegFile('thumbnail.jpg');

// same as above specifying a quality value (higher quality means larger file size)
$thumbnailr->to_jpeg_file('thumbnail.png', 80);
$thumbnailr->toJpegFile('thumbnail.jpg', 80);

// get the JPEG thumbnail as a base 64 string, use standard quality
$jpeg_b64 = $thumbnailr->to_jpeg_base_64();
$jpeg_b64 = $thumbnailr->toJpegBase64();

// same as the above specifying a quality value
$jpeg_b64 = $thumbnailr->to_jpeg_base_64(40);
$jpeg_b64 = $thumbnailr->toJpegBase64(40);
```

0 comments on commit 1feda01

Please sign in to comment.