获取SWF文件尺寸与Python的最佳方法 [英] Best way of Getting Swf File Dimensions with Python

查看:1040
本文介绍了获取SWF文件尺寸与Python的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编辑:

我在考虑hexagonit和swfTools。没有人有任何其他的解决方案,或洞察力? 编辑:

I'm considering hexagonit, and swfTools. Does anyone have any other solutions, or insight?

新问题 - 如何解决这个错误: 我试着用hexagonit.swfheader但是我收到的错误:

New Question - how to solve this error: I tried using hexagonit.swfheader however I receive the error:

 f = 'out/'+w+"/"+s+"/"+"theSwf/"+s
 data = hexagonit.swfheader.parse(f)
 File "/Library/Python/2.7/site-packages/hexagonit/swfheader/__init__.py", line 26, in parse
 signature = ''.join(struct.unpack('<3c', input.read(3)))  
 struct.error: unpack requires a string argument of length 3

通过这个跟踪后,我发现这里发生了错误:

After tracing through this I found that the error occurs here:

def parse(input):
"""Parses the header information from an SWF file."""
need_close=False
if hasattr(input, 'read'):
    input.seek(0)
else:
    input = open(input, 'rb')*
    need_close=True

*是发生错误。

我读:<一href="http://stackoverflow.com/questions/5136317/get-dimensions-from-a-flash-file-swf-in-pure-python">Get从纯Python中的Flash文件(.swf文件)尺寸

我也尝试过使用PIL和枕头不过,我在IM pression,他们比较图像不SWF文件。我反编译SWF文件的我期待在沿,但也有swf文件本身。

I have also tried using PIL and Pillow however I am under the impression that they compare images not swf files. I decompiled the swf file's I'm looking at along but also have the swf file itself.

我想知道什么大小的文件显示为(尺寸)。

I would like to know what size the file displays as (dimensions).

我的第一个想法是尝试使用图像的大小比较。

My first thought was to try using image size comparison.

我的问题,这是那些在SWF作为资产的部分图像实际上比SWF本身较大,否则我会用PIL简单地获取最大的图像资源(例如背景)的尺寸。

My issue with this is that some images that are used as assets in the swf are actually larger than the swf itself, otherwise I would use PIL to simply get the dimensions of the largest image asset (ex the background).

其次我的另一个问题是,同样可以比较SVG和PNG文件..和枕头和弼据我所知,不处理SVG文件。

Secondly my other issue is that can equally compare svg and png files.. and Pillow and Pil to my knowledge do not handle svg files.

我的第二个想法是搜索动作code的尺寸。

My second idea was to search the actionscript code for the dimensions.

有些文件在他们的行动脚本像300×300这表示大小。之后,不幸的是在寻找最让我感到有工作的文件并不意味着这主要是无益的。

Some files have in their action script something like 300x300 which denotes the size. Unfortunately after looking at most of the files I am working with do not which means this is largely unhelpful.

我的第三个想法是忽略了反编译SWF数据,而专注于SWF本身。

My 3rd idea was to ignore the decompiled swf data and rather focus on the swf itself.

我可以在理论上或者试图找到在字节code尺寸(或使用一个库,做到这一点(我需要找到一个作为点子和枕头似乎不工作)),或者我需要运行广告,然后截图,并试图找到该广告的启动和停止,并计算基础上的像素。我的问题与屏幕shotting那就是图像可能会融入背景,使其很难甚至无法得到正确的尺寸,但更重要的是许多主权财富基金不能播放,由于安全,如果他们在正确的网址都没有出场,等

I could in theory either try to find the dimensions in the byte code (or use a library that does this (which I need to find one as pip and pillow do not appear to work)) or I need to run the ad and then screenshot it and try to find where the ad starts and stops and calculate the pixels based on that. My problem with screens shotting it is that the image may blend into the background and make it hard if not impossible to get the correct dimensions, but more importantly many swfs cannot be played due to security if they are not played in the right url, etc.

于是我留下了一个两难境地。我想,去了解这将是使用的swf文件本身的最佳途径。

Thus I'm left with a dilemma. I think the best way to go about this would be to use the swf file itself.

推荐答案

先看看官方的<一个href="http://wwwimages.adobe.com/www.adobe.com/content/dam/Adobe/en/devnet/swf/pdf/swf-file-format-spec.pdf"相对=nofollow> SWF文件格式规范。你正在寻找的维度信息应该是正确的靠近文件的开头。看看一节的S​​WF头

Take a look at the official SWF file format spec. The dimension info you are looking for should be right near the beginning of the file. Take a look at the section "The SWF header"

The FrameSize field defines the width and height of the on-screen display. This field is stored as a RECT 
structure, meaning that its size may vary according to the number of bits needed to encode the coordinates. The 
FrameSize RECT always has Xmin and Ymin value of 0; the Xmax and Ymax members define the width and height 
(see Using bit values).

这篇关于获取SWF文件尺寸与Python的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆