Skip to content

Special character handling #3

Description

@onilton

Some special characters, ie. '(' and ')' causes a error when generating the new image.

It's a problem with the command. You have to add " ' " to make sure these characters are handled correctly. To fix it, just replace.

                        if(isset($opts['scale']) && $opts['scale'] == true):
                                $cmd = $path_to_convert." ".$imagePath." -resize ".$resize." -quality ".$quality." ".$newPath;
                        else:
                                $cmd = $path_to_convert." ".$imagePath." -resize ".$resize." -size ".$w."x".$h." xc:".(isset($opts['canvas-color'])?$opts['canvas-color']:"transparent")." +swap -gravity center -composite -quality ".$quality." ".$newPath;
                        endif;

                else:
                        $cmd = $path_to_convert." ".$imagePath." -thumbnail ".(!empty($h) ? 'x':'').$w."".(isset($opts['maxOnly']) && $opts['maxOnly'] == true ? "\>" : "")." -quality ".$quality." ".$newPath;
                endif;

With this:

                        if(isset($opts['scale']) && $opts['scale'] == true):
                                $cmd = $path_to_convert." '".$imagePath."' -resize ".$resize." -quality ".$quality." ".$newPath;
                        else:
                                $cmd = $path_to_convert." '".$imagePath."' -resize ".$resize." -size ".$w."x".$h." xc:".(isset($opts['canvas-color'])?$opts['canvas-color']:"transparent")." +swap -gravity center -composite -quality ".$quality." ".$newPath;
                        endif;

                else:
                        $cmd = $path_to_convert." '".$imagePath."' -thumbnail ".(!empty($h) ? 'x':'').$w."".(isset($opts['maxOnly']) && $opts['maxOnly'] == true ? "\>" : "")." -quality ".$quality." ".$newPath;
                endif;

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions