Skip to content

Commit

Permalink
Implementation of extra functions
Browse files Browse the repository at this point in the history
Implementation of extra functions regarding issue #1
  • Loading branch information
joserick committed Nov 2, 2020
1 parent bb6b410 commit 1f27701
Show file tree
Hide file tree
Showing 2 changed files with 206 additions and 24 deletions.
45 changes: 41 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Welcome to PNGMetadata!
# Welcome to PNGMetadata!

PNGMetadata is a library which is able to extract the metadata of an image in png format.

Expand Down Expand Up @@ -53,7 +53,7 @@ $metadata_array = PNGMetadata::extract('Photo.png')->toArray(); // return simple

## Examples

### Example 1
### Example 1 - All

Print all the metadata.

Expand All @@ -71,7 +71,7 @@ Out:
| exif:MimeType | image/png |
| ... | ... |

### Example 2
### Example 2 - Get Metadata

Get specific metadata.

Expand All @@ -80,7 +80,7 @@ $png_metadata = new PNGMetadata(___DIR___.'/Photo.png');
echo $png_metadata->get('exif:DateTime'); // Return a value, a array or false.
```

### Example 3
### Example 3 - Types

Print the metadata types (IHDR, SRBG, BKGD, EXIF, XMP, CRS, DATE, DC, ICC, AUX, ...).

Expand All @@ -94,6 +94,43 @@ foreach($png_metadata as $key => $value){
}
```

## Extras Functions

### Get the thumbnail stored in the metadata!
```php
$png_metadata = new PNGMetadata('../Photo.png');
// or
$png_metadata = PNGMetadata::extract('../Photo.png');

$thumb = $png_metadata->getThumbnail();

if ($thumb !== false) {
header('Content-Type: image/png');
imagepng($thumb);
imagedestroy($thumb);
}
```

### Is PNG?
```php
if (PNGMetadata::isPNG('./Photo_jpg.png')){

This comment has been minimized.

Copy link
@janbarasek

janbarasek Nov 3, 2020

Contributor

CS: )){ => )) {

This comment has been minimized.

Copy link
@joserick

joserick Nov 4, 2020

Author Owner

Repaired.

echo 'Yes, it is a PNG.';
}else{

This comment has been minimized.

Copy link
@janbarasek

janbarasek Nov 3, 2020

Contributor

CS: } else {

This comment has been minimized.

Copy link
@joserick

joserick Nov 4, 2020

Author Owner

Repaired.

echo 'No, it is not a PNG.'
}
```

### What type?
| | | | | | |
|:----------:|:----------:|:--------:|:-------:|:--------:|:-------:|
| GIF(1) | JPEG(2) | PNG (3) | SWF(4) | PSD(5) | BMP(6) |
| TIFF_II(7) | TIFF_MM(8) | JP2 (10) | JPX(11) | JB2(12) | SWC(13) |
| IFF(14) | WBMP(15) | XBM(16) | ICO(17) | WEBP(18) | |

```php
return PNGMetadata::getType('./Photo') == 1 // GIF?

This comment has been minimized.

Copy link
@janbarasek

janbarasek Nov 3, 2020

Contributor

Please always use strict comparison with boolean or constant (for example PNGMetadata::TYPE_GIF).

This comment has been minimized.

Copy link
@joserick

joserick Nov 4, 2020

Author Owner

Repaired.

```

## License

The GNU Public License (GPLv3). Please see [License File](https://github.com/joserick/PNGMetadata/blob/master/LICENSE) for more information.
Loading

0 comments on commit 1f27701

Please sign in to comment.