Adjustments to transcoding to allow psd transcoding to actually work
Changed resize extension to run later in the extension stack Little fixes
This commit is contained in:
		
							parent
							
								
									3269d32378
								
							
						
					
					
						commit
						1aa0225652
					
				@ -201,12 +201,13 @@ function create_thumbnail_convert($hash): bool
 | 
			
		||||
        $options .= "\>";
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    $bg = "black";
 | 
			
		||||
    if($type=="webp") {
 | 
			
		||||
        $format = '"%s" -thumbnail %ux%u%s -quality %u -background none "%s[0]"  %s:"%s"';
 | 
			
		||||
    } else {
 | 
			
		||||
        $format = '"%s" -flatten -strip -thumbnail %ux%u%s -quality %u "%s[0]" %s:"%s"';
 | 
			
		||||
        $bg = "none";
 | 
			
		||||
    }
 | 
			
		||||
    $cmd = sprintf($format, $convert, $w, $h, $options, $q, $inname, $type, $outname);
 | 
			
		||||
    $format = '"%s" -flatten -strip -thumbnail %ux%u%s -quality %u -background %s "%s[0]"  %s:"%s"';
 | 
			
		||||
 | 
			
		||||
    $cmd = sprintf($format, $convert, $w, $h, $options, $q, $bg, $inname, $type, $outname);
 | 
			
		||||
    $cmd = str_replace("\"convert\"", "convert", $cmd); // quotes are only needed if the path to convert contains a space; some other times, quotes break things, see github bug #27
 | 
			
		||||
    exec($cmd, $output, $ret);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -265,7 +265,8 @@ const MIME_TYPE_MAP = [
 | 
			
		||||
    'avi' => 'video/x-msvideo', 'mpg' => 'video/mpeg', 'mpeg' => 'video/mpeg',
 | 
			
		||||
    'mov' => 'video/quicktime', 'flv' => 'video/x-flv', 'php' => 'text/x-php',
 | 
			
		||||
    'mp4' => 'video/mp4', 'ogv' => 'video/ogg', 'webm' => 'video/webm',
 | 
			
		||||
    'webp' => 'image/webp', 'bmp' =>'image/x-ms-bmp'
 | 
			
		||||
    'webp' => 'image/webp', 'bmp' =>'image/x-ms-bmp', 'psd' => 'image/vnd.adobe.photoshop',
 | 
			
		||||
    'mkv' => 'video/x-matroska'
 | 
			
		||||
];
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 | 
			
		||||
@ -16,6 +16,15 @@
 | 
			
		||||
 */
 | 
			
		||||
class ResizeImage extends Extension
 | 
			
		||||
{
 | 
			
		||||
    /**
 | 
			
		||||
     * Needs to be after the data processing extensions
 | 
			
		||||
     */
 | 
			
		||||
    public function get_priority(): int
 | 
			
		||||
    {
 | 
			
		||||
        return 55;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
    public function onInitExt(InitExtEvent $event)
 | 
			
		||||
    {
 | 
			
		||||
        global $config;
 | 
			
		||||
 | 
			
		||||
@ -87,7 +87,7 @@ class TranscodeImage extends Extension
 | 
			
		||||
    ];
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Need to be after upload, but before the processing extensions
 | 
			
		||||
     * Needs to be after upload, but before the processing extensions
 | 
			
		||||
     */
 | 
			
		||||
    public function get_priority(): int
 | 
			
		||||
    {
 | 
			
		||||
@ -238,7 +238,7 @@ class TranscodeImage extends Extension
 | 
			
		||||
                            if($image==null) {
 | 
			
		||||
                                continue;
 | 
			
		||||
                            }
 | 
			
		||||
            
 | 
			
		||||
                            
 | 
			
		||||
                            $this->transcode_and_replace_image($image, $format);
 | 
			
		||||
                            // If a subsequent transcode fails, the database need to have everything about the previous transcodes recorded already,
 | 
			
		||||
                            // otherwise the image entries will be stuck pointing to missing image files
 | 
			
		||||
@ -424,20 +424,20 @@ class TranscodeImage extends Extension
 | 
			
		||||
        }
 | 
			
		||||
        $ext = $this->determine_ext($target_format);
 | 
			
		||||
 | 
			
		||||
        $args = "-flatten";
 | 
			
		||||
        $args = " -flatten ";
 | 
			
		||||
        $bg = "none";
 | 
			
		||||
        switch($target_format) {
 | 
			
		||||
            case "webp-lossless":
 | 
			
		||||
                $args = '-define webp:lossless=true';
 | 
			
		||||
                $args .= '-define webp:lossless=true';
 | 
			
		||||
                break;
 | 
			
		||||
            case "webp-lossy":
 | 
			
		||||
                $args = '';
 | 
			
		||||
                $args .= '';
 | 
			
		||||
                break;
 | 
			
		||||
            case "png":
 | 
			
		||||
                $args = '-define png:compression-level=9';
 | 
			
		||||
                $args .= '-define png:compression-level=9';
 | 
			
		||||
                break;
 | 
			
		||||
            default:
 | 
			
		||||
                $bg = "white";
 | 
			
		||||
                $bg = "black";
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
        $tmp_name = tempnam("/tmp", "shimmie_transcode");
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user