diff options
Diffstat (limited to 'src/photos')
-rw-r--r-- | src/photos/PhotoMetadata.vala | 8 | ||||
-rw-r--r-- | src/photos/WebPSupport.vala | 16 |
2 files changed, 23 insertions, 1 deletions
diff --git a/src/photos/PhotoMetadata.vala b/src/photos/PhotoMetadata.vala index 3bf77d6..0624b41 100644 --- a/src/photos/PhotoMetadata.vala +++ b/src/photos/PhotoMetadata.vala @@ -1043,7 +1043,13 @@ public class PhotoMetadata : MediaMetadata { }; public override string? get_comment() { - return get_first_string_interpreted (COMMENT_TAGS); + var comment = get_first_string_interpreted (COMMENT_TAGS); + try { + var re = new Regex("^charset=\\w+\\s*"); + return re.replace(comment, -1, 0, "", RegexMatchFlags.DEFAULT); + } catch (Error err) { + return comment; + } } public void set_comment(string? comment, diff --git a/src/photos/WebPSupport.vala b/src/photos/WebPSupport.vala index 2f4723c..543c889 100644 --- a/src/photos/WebPSupport.vala +++ b/src/photos/WebPSupport.vala @@ -183,7 +183,13 @@ private class WebpSniffer : PhotoFileSniffer { if (calc_md5) detected.md5 = md5_checksum.get_string(); + // We have never reached the header parsing state, but also didn't encounter any error + if (detected.file_format != PhotoFileFormat.WEBP) { + return null; + } + return detected; + } } @@ -203,8 +209,18 @@ private class WebpReader : PhotoFileReader { uint8[] buffer; FileUtils.get_data(this.get_filepath(), out buffer); + var features = WebP.BitstreamFeatures(); + WebP.GetFeatures(buffer, out features); + + if (features.has_animation) { + throw new IOError.INVALID_DATA("Animated WebP files are not yet supported"); + } + int width, height; var pixdata = WebP.DecodeRGBA(buffer, out width, out height); + if (pixdata == null) { + throw new IOError.INVALID_DATA("Failed to decode WebP file"); + } pixdata.length = width * height * 4; return new Gdk.Pixbuf.from_data(pixdata, Gdk.Colorspace.RGB, true, 8, width, height, width * 4); |