PHP code example of ronanlenouvel / raw-preview-extractor
1. Go to this page and download the library: Download ronanlenouvel/raw-preview-extractor library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
ronanlenouvel / raw-preview-extractor example snippets
use RonanLenouvel\RawPreviewExtractor\Exception\RawPreviewExtractorException;
use RonanLenouvel\RawPreviewExtractor\RawPreviewExtractor;
$extractor = RawPreviewExtractor::createDefault();
try {
$preview = $extractor->extract('/path/to/photo.cr2');
file_put_contents('/path/to/thumbnail.jpg', $preview->jpegData);
echo $preview->width, 'x', $preview->height;
echo $preview->sourceFormat->name;
} catch (RawPreviewExtractorException) {
// Every exception thrown by this package implements this interface,
// so a single catch is enough to degrade gracefully.
}
$preview->orientation; // Orientation::Rotate90
$preview->orientation->degrees(); // 90
$preview->orientation->isUpright(); // false
$preview->orientation->isMirrored(); // false — 4 of the 8 EXIF values are mirrors
$preview->orientation->swapsDimensions(); // true — width and height swap on a quarter turn