SWF handling module

mebigrock

Joined: 2005-11-30
Posts: 3
Posted: Wed, 2005-11-30 19:51

After much searching of the forums and fiddling about with any options I can find, I've given up on waiting for someone else to do the work and I've written a little (very little) module that discovers the size (height and width) of an swf when you upload it. That is all it does at the moment, though in the future I'm planning on adding some advanced features for handling SWFs.

This means that you no longer have to go into the edit animation screen and manually enter (sometimes guess) the size of the animation. I thought I would share it with you as I've noticed a couple of other people on the forum struggling with the same problem.

This is my first attempt at writing a module for gallery, so please give me plenty of feedback on it and if anyone has some ideas for where to go with this in the future I would be happy to listen.

--
Malcolm

AttachmentSize
swf.zip2.84 KB
 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-11-30 23:32

thanks, great!

- your .zip file contains a lot of dev files. but the toolkit looks good.
- so you're using the GD function getimagesize.

IMO, we should extend the GD module to also discover the swf dimensions in the GD module, all GD operations should be part of the GD module.
for now, let's use your module for swf, but sooner or later, we'll merge this functionality into the GD module. should be a small change.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 03:20

i've added your module on http://codex.gallery2.org/index.php/Gallery2:User_Contributions#Modules

you can edit the page (you just need to register on codex.gallery2.org).
if you haven't already done so, please clean up the zip (don't include your dev environment) .
also please add a check if GD is present. see modules/gd/module.inc on how to check for the presence of GD and not allow activating /configuring the module if GD is not available.

 
mebigrock

Joined: 2005-11-30
Posts: 3
Posted: Thu, 2005-12-01 08:00

Thanks for your comments, much appreciated!

According to the php manual (http://uk2.php.net/manual/en/function.getimagesize.php), the getimagesize function doesn't need and isn't part of the GD library which is why I didn't put a check in for it. I believe that the function only requires any version of PHP 4 or above.

I think the dev files you are talking about are just the junk that OS X puts into its zip files, here's a version created using the command line that shouldn't have the same problem.

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Thu, 2005-12-01 12:02
Quote:
According to the php manual (http://uk2.php.net/manual/en/function.getimagesize.php), the getimagesize function doesn't need and isn't part of the GD library which is why I didn't put I check in for it.

oh, i didn't realize that. perfect then. keeping it in a separate swf toolkit makes sense.
i guess it makes sense to have a highly specialized toolkit just for swf/animation items.
thanks for contributing!

 
parki

Joined: 2005-12-06
Posts: 18
Posted: Wed, 2005-12-07 03:53

Works great !
Anybody knows how I can add a miniature image to an swf file ?
(doesn't have to be autogenerated).

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Wed, 2005-12-07 04:51
 
mebigrock

Joined: 2005-11-30
Posts: 3
Posted: Thu, 2005-12-08 09:35

I've been looking for a way to autogenerate some sort of thumbnail from swfs but it doesn't seem to be possible, so I've been manually creating and uploading jpeg thumbnails for each one...

If anyone has any ideas on how to do this it would be very helpful. One thing that I thought of would be just to use the swf itself as a thumbnail - would that be possible, or do thumbnails have to be jpegs?

 
OBTUSE

Joined: 2005-12-30
Posts: 1
Posted: Sat, 2005-12-31 08:47

Suddenly, on implementing this module, my guests have access to 'create link' for the animations. Any ideas on how I can turn this off?.

Thanks.

 
Eka_Mei

Joined: 2006-01-03
Posts: 132
Posted: Mon, 2006-03-13 00:18

Anyone planning on having this updated to 2.1?

 
phosphor

Joined: 2006-04-10
Posts: 3
Posted: Thu, 2006-04-13 10:25

I have updated to 2.1.
More detail about the php function getimagesize() you can found at:
http://www.php.net/function.getimagesize

 
Eka_Mei

Joined: 2006-01-03
Posts: 132
Posted: Thu, 2006-04-13 21:05

Appear to work so far. Thank you!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2006-04-21 05:38

all of our image toolkits try getimagesize before using their own functions, so i'll just add the application/x-shockwave-flash mime type to all three.

 
jfee

Joined: 2006-05-06
Posts: 2
Posted: Sat, 2006-05-06 00:48

This module is wonderful, however it would not resize to fit the maximum dimensions settings.

I have modified (a simple conditional line) /classes/SwfToolkit.class to limit the size. I currently have it set to limit the width to 400, but you can change the desired maximum width by changing the numbers on lines 65 and 67. Not the cleanest coding but it works.

I did not make a conditional statement for height as it is not necessary.

The reason I did this was because I am using Gallery2 bridged into Joomla! and my template would get screwed up if the image was too wide.

Nice work though!

EDIT: I didn't zip it so you'll have to get rid of the .txt when you upload to your server.

EDIT2:

I made a big error... it doesn't keep it relative. Replace the conditional with this:

Quote:
/***LIMIT TO 400PX***/

if($width > 450){

$difference = 450 / $width;

$width = $width * $difference;
$height = $height * $difference;

}

/********************/

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sat, 2006-05-06 16:28

FYI, there's a utility function in GalleryUtilities to resize dimensions.

 
NBrady

Joined: 2005-10-07
Posts: 77
Posted: Wed, 2006-09-13 23:47

Would it be at all possible ot put in some sorta playback bar? Maybe even watermark the actual video?

Kinda like a youtube-esque setup?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2006-09-17 00:49

Swf handling broken in latest build.

I just installed the latest 2.2svn on my friend's site.
When I upload a swf, it is treated like a file(edit file/delete file...) and produces a "Download file" link.
His version:
@g2 <class-name>GalleryAnimationItem</class-name>
@package GalleryCore
* @subpackage Classes
* @author Bharat Mediratta <bharat@menalto.com>
* @version $Revision: 14480 $ $Date: 2006-09-08 18:26:55 -0700 (Fri, 08 Sep 2006)

My version:
@version $Revision: 13634 $ $Date: 2006-05-10 15:44:00 -0500 (Wed, 10 May 2006) $

Everything works fine, it detects the size, displays the swf and treats it like an animation(edit animation/delete animation...).

Did we break something?
Can we fix it?

-s

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-09-17 05:13

there are only phpdoc changes in that file between those revisions.
G2 will switch to "file" if the dimensions detection fails on initial upload.. I guess something on that site makes that not work?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2006-09-17 22:25

But shouldn't it stay an animation if thats what it is? And we enter the dimesions manually it getproperty fails.

His server is a freebsd machine. We had another site on it with a very early 2.2svn in which swfs displayed properly(I think with the help of the now defunct swf module which I tried last night - no help).

Any suggestion as to bypassing the switch to file on getproperty failure?

-s

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-09-17 23:12

i think the code is written on the assumption that the dimensions-detector works, so if it fails maybe it wasn't really a swf file; so stores it as "file".
you can modify rescan() in GalleryAnimationItem if you want to change this behavior (ignore toolkit error instead of adding ERROR_BAD_DATA_TYPE).