Add webp support to image type. Can't make thumbnails on (ancient) moon

This commit is contained in:
Junior 2023-08-30 15:11:59 -04:00
parent feb69966d6
commit 5b49a8b6e4
2 changed files with 14 additions and 9 deletions

View File

@ -44,8 +44,9 @@ if ( $ext == "cbz" ) {
$opened = $zip->open($comicfull); $opened = $zip->open($comicfull);
for ( $i=0; $i<$zip->numFiles; $i++ ) { for ( $i=0; $i<$zip->numFiles; $i++ ) {
$imgname = basename($zip->getNameIndex($i)); $imgname = basename($zip->getNameIndex($i));
$myext = substr($imgname, -3); //$myext = substr($imgname, -3);
if ( ($myext == "jpg") || ($myext == "png") ) { $myext = strtolower(pathinfo($imgname)['extension']);
if ( ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
$imgname = str_replace("#", "", $imgname); $imgname = str_replace("#", "", $imgname);
$imgcontents = $zip->getFromIndex($i); $imgcontents = $zip->getFromIndex($i);
$written = file_put_contents($comicoutputfull . $imgname, $imgcontents); $written = file_put_contents($comicoutputfull . $imgname, $imgcontents);
@ -58,8 +59,9 @@ if ( $ext == "cbz" ) {
while ( false !== ($file = readdir($fh)) ) { while ( false !== ($file = readdir($fh)) ) {
$myfile = $comicoutputfull . $file; $myfile = $comicoutputfull . $file;
$mynewfile = $comicoutputfull . str_replace("#", "", $file); $mynewfile = $comicoutputfull . str_replace("#", "", $file);
$myext = strtolower(substr($file, -3)); //$myext = strtolower(substr($file, -3));
if ( ($myext == "jpg") || ($myext == "png") ) { $myext = strtolower(pathinfo($imgname)['extension']);
if ( ($myext == "jpg") || ($myext == "png") || ($myext == "webp") ) {
rename($myfile, $mynewfile); rename($myfile, $mynewfile);
$files[] = basename($mynewfile); $files[] = basename($mynewfile);
} }

View File

@ -45,9 +45,11 @@ function makeThumb($item = "") {
$imgdata = null; $imgdata = null;
for ( $i=0; $i<$zip->numFiles; $i++ ) { for ( $i=0; $i<$zip->numFiles; $i++ ) {
$imgname = basename($zip->getNameIndex($i)); $imgname = basename($zip->getNameIndex($i));
$imgext = strtolower(pathinfo($imgname)['extension']);
if ( (strcmp($lowest, $imgname) > 0) if ( (strcmp($lowest, $imgname) > 0)
&& ((strcasecmp(substr($imgname, -3), "jpg") == 0) && ((strcasecmp($imgext, "jpg") == 0)
|| (strcasecmp(substr($imgname, -3), "png") == 0)) ) { || (strcasecmp($imgext, "png") == 0)
|| (strcasecmp($imgext, "webp") == 0)) ) {
$lowest = $imgname; $lowest = $imgname;
$imgdata = $zip->getFromIndex($i); $imgdata = $zip->getFromIndex($i);
} }
@ -63,11 +65,12 @@ function makeThumb($item = "") {
$lowest = "~"; $lowest = "~";
foreach ( $entries as $entry ) { foreach ( $entries as $entry ) {
$imgname = $entry->getName(); $imgname = $entry->getName();
$imgext = strtolower(pathinfo($imgname)['extension']);
if ( (strcmp($lowest, $imgname) > 0) if ( (strcmp($lowest, $imgname) > 0)
&& ((strcasecmp(substr($imgname, -3), "jpg") == 0) && ((strcasecmp($imgext, "jpg") == 0)
|| (strcasecmp(substr($imgname, -3), "png") == 0)) ) { || (strcasecmp($imgext, "png") == 0)
|| (strcasecmp($imgext, "webp") == 0)) ) {
$lowest = $imgname; $lowest = $imgname;
$ext = strtolower(substr($imgname, -3));
$didwrite = $entry->extract(false, $outfile); $didwrite = $entry->extract(false, $outfile);
if ( !$didwrite ) { return false; } if ( !$didwrite ) { return false; }
} }