Bug found and remedied in core code - missing_movie.png copied as jpg in graphics.php

shadlaws

Joined: 2012-03-14
Posts: 175
Posted: Wed, 2012-03-28 10:23

Hey everyone,

In debugging my proofsheet module, I discovered a problem with graphics.php, namely in the generate($item) function. The problem is that missing_movie.png is copied as a jpg to the target thumbnails directory. This causes problems if programs expect things that end in jpg to be jpg files.

The bug can be found here:

  static function generate($item) {

        ...

        if ($input_item->is_movie()) {
          // Convert the movie to a JPG first
          $output_file = preg_replace("/...$/", "jpg", $output_file);
          try {
            movie::extract_frame($input_file, $output_file);
          } catch (Exception $e) {
            // Assuming this is MISSING_FFMPEG for now
            copy(MODPATH . "gallery/images/missing_movie.png", $output_file);
          }
          $working_file = $output_file;
        } else {
          $working_file = $input_file;
        }

        ...

  }

The file missing_movie.png is copied to $output_file, which is predefined with a jpg extension. Whoops.

I figure there are two possible solutions:

  • convert missing_movie.png to a jpg, then edit graphics.php to point to the jpg file instead.
  • fix graphics.php to correctly assign the thumbnail as a png file.

It seems that the first solution is less likely to break downstream modules than the second solution, and is the one I implemented on my installation. For those interested, I've attached the missing_movie.jpg file you'd need.

Sidenote: I've also modified my proofsheet module so it's impervious to the problem by making it determine file type by file header instead of file extension.

Thanks,
Shad

AttachmentSize
missing_movie.jpg8.99 KB
 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 25938
Posted: Wed, 2012-03-28 15:16

Cheers!
I have created https://sourceforge.net/apps/trac/gallery/ticket/1828 so it does not get lost in the forums.

Dave
_____________________________________________
Blog & G2 || floridave - Gallery Team

 
MarkRH

Joined: 2007-05-25
Posts: 214
Posted: Thu, 2012-03-29 23:49

With the few videos I have, I usually upload my own 200x200 jpg thumbnail image to replace the one that's made. Thanks for pointing that out though.

Thanks,
Mark H.

Using Gallery 3.0.2 - gallery.markheadrick.com

 
shadlaws

Joined: 2012-03-14
Posts: 175
Posted: Fri, 2012-03-30 15:38

@floridave - thanks for posting it at sourceforge! Sorry I didn't do it myself... I'm still a bit of a noob as far as gallery management logistics goes. Next time I'll do it myself and spare you the trouble :-)

@MarkRH - aye, it's a pretty minor problem for 99.9% of people, and most things don't care if you feed them mis-extensioned graphic files. It just so happens that FPDF does care, and I hadn't yet made my code robust against it.

Take care,
Shad

 
floridave
floridave's picture

Joined: 2003-12-22
Posts: 25938
Posted: Tue, 2012-05-08 04:45
floridave wrote:
Cheers!
I have created https://sourceforge.net/apps/trac/gallery/ticket/1828 so it does not get lost in the forums.

Fixed: https://github.com/gallery/gallery3/commit/a563dcdfb32d34d4cd22c5c75fa7f02f7b7b08d9

_____________________________________________
Blog & G2 || floridave - Gallery Team

 
shadlaws

Joined: 2012-03-14
Posts: 175
Posted: Mon, 2012-05-14 07:56

Sweet - thanks!

Take care,
Shad