Skip to content
This repository has been archived by the owner on Nov 27, 2023. It is now read-only.

Commit

Permalink
adds getImageSize to get image width and height
Browse files Browse the repository at this point in the history
  • Loading branch information
cdowdy committed Mar 2, 2017
1 parent 27e377c commit 8a0bca3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Controller/TinyPNGBackendController.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,8 @@ public function before( Request $request, Application $app ) {
* @return mixed
*/
public function allImages( Application $app ) {
$adapter = new Local( $app['resources']->getPath( 'filespath' ) );
$boltFilesPath = $app['resources']->getPath( 'filespath' );
$adapter = new Local( $boltFilesPath );
$filesystem = new Filesystem( $adapter );
$fileList = $filesystem->listContents( null, true );

Expand All @@ -112,12 +113,18 @@ public function allImages( Application $app ) {
&& in_array( strtolower( $filesystem->getMimetype( $object['path'] ) ), $expectedMimes )
) {

$imageWidthHeight = getimagesize($boltFilesPath . '/' . $object['path']);
$width = $imageWidthHeight[0];
$height = $imageWidthHeight[1];

$files[] = [
'filename' => $object['basename'],
'located' => $object['dirname'],
'imagePath' => $object['path'],
'mimeType' => $filesystem->getMimetype( $object['path'] ),
'filesize' => self::bytesToHuman( $filesystem->getSize( $object['path'] ) ),
'imageWidth' => $width,
'imageHeight' => $height,
];
}
}
Expand Down

0 comments on commit 8a0bca3

Please sign in to comment.