Permalink
Browse files

When restoring JPEG headers to a resized image, delete any existing h…

…eaders that are present in the image before restoring the original headers.

Some browsers may retain part of the header data in the resized image, so these retained headers need to be overwritten with the original data.
  • Loading branch information...
1 parent 7ef076d commit 269f4e2375434e1a9426d757454160fd3d29f488 Kevin Jamieson committed Apr 13, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 src/javascript/plupload.html5.js
@@ -869,10 +869,19 @@
read.init(data);
// Check if data is jpeg
- if (read.SHORT(0) !== 0xFFD8) {
+ var jpegHeaders = new JPEG_Headers(data);
+
+ if (!jpegHeaders['headers']) {
return false;
}
+ // Delete any existing headers that need to be replaced
+ for (var i = jpegHeaders['headers'].length; i > 0; i--) {
+ var hdr = jpegHeaders['headers'][i - 1];
+ read.SEGMENT(hdr.start, hdr.length, '')
+ }
+ jpegHeaders.purge();
+
idx = read.SHORT(2) == 0xFFE0 ? 4 + read.SHORT(4) : 2;
for (var i = 0, max = headers.length; i < max; i++) {

0 comments on commit 269f4e2

Please sign in to comment.