You are here: Foswiki>Tasks Web>Item13895 (08 Dec 2016, GeorgeClark)Edit Attach

Item13895: rest/ImagePlugin/resize returns corrupt data

pencil
Priority: Urgent
Current State: Closed
Released In: n/a
Target Release: n/a
Applies To: Extension
Component: ImagePlugin
Branches: master
Reported By: AndreLichtsteiner
Waiting For:
Last Change By: GeorgeClark
SolrPlugin includes nice image preview on the result page.

The images get fetched via /bin/rest/ImagePlugin/resize?.....

In Foswiki 2.0.3, ISO Store, we observer now, that the jpg previews data gets wrongly utf encoded.

I don't know, whether this is a bug of the Plugin or a shortcoming of the Rest API in core.

-- AndreLichtsteiner - 14 Dec 2015

It's a bug in the plugin. binary data should be output using response->body() text with response->print() Thanks CDot for the reminder. Try the following patch (not tested)
diff --git a/lib/Foswiki/Plugins/ImagePlugin/Core.pm b/lib/Foswiki/Plugins/ImagePlugin/Core.pm
index 36b3308..0653f13 100644
--- a/lib/Foswiki/Plugins/ImagePlugin/Core.pm
+++ b/lib/Foswiki/Plugins/ImagePlugin/Core.pm
@@ -169,7 +169,7 @@ sub handleREST {
     );
 
     my $image = readImage($imgWeb, $imgTopic, $imgInfo);
-    $response->print($image);
+    $response->body($image);
   }
 
   return;

MichaelDaum, can you review this. Plugin is CoordinateWithAuthor See TestItem13895 for a demonstration.

-- GeorgeClark - 14 Dec 2015

Thanks for the patch. I will add it to the next release. I didn't realize the error before as I use XSendFileContrib to deliver attachments and thumbnails for better performance.

-- MichaelDaum - 15 Dec 2015

Yeah, patch works fine.

-- Main.AndreLichtsteiner - 21 Dec 2015 - 09:54

 
Topic revision: r7 - 08 Dec 2016, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy