Mercurial > hg > soundsoftware-site
comparison .svn/pristine/4b/4b6f435406424f568a3074e07ecf7adb9983d62f.svn-base @ 1295:622f24f53b42 redmine-2.3
Update to Redmine SVN revision 11972 on 2.3-stable branch
author | Chris Cannam |
---|---|
date | Fri, 14 Jun 2013 09:02:21 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1294:3e4c3460b6ca | 1295:622f24f53b42 |
---|---|
1 # The MIT License | |
2 # | |
3 # Permission is hereby granted, free of charge, to any person obtaining a copy | |
4 # of this software and associated documentation files (the "Software"), to deal | |
5 # in the Software without restriction, including without limitation the rights | |
6 # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
7 # copies of the Software, and to permit persons to whom the Software is | |
8 # furnished to do so, subject to the following conditions: | |
9 # | |
10 # The above copyright notice and this permission notice shall be included in | |
11 # all copies or substantial portions of the Software. | |
12 # | |
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | |
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
18 # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
19 # THE SOFTWARE. | |
20 # | |
21 # This implements native php methods used by tcpdf, which have had to be | |
22 # reimplemented within Ruby. | |
23 | |
24 module RFPDF | |
25 | |
26 # http://uk2.php.net/getimagesize | |
27 def getimagesize(filename) | |
28 image = Magick::ImageList.new(filename) | |
29 | |
30 out = Hash.new | |
31 out[0] = image.columns | |
32 out[1] = image.rows | |
33 | |
34 # These are actually meant to return integer values But I couldn't seem to find anything saying what those values are. | |
35 # So for now they return strings. The only place that uses this at the moment is the parsejpeg method, so I've changed that too. | |
36 case image.mime_type | |
37 when "image/gif" | |
38 out[2] = "GIF" | |
39 when "image/jpeg" | |
40 out[2] = "JPEG" | |
41 when "image/png" | |
42 out[2] = "PNG" | |
43 when " image/vnd.wap.wbmp" | |
44 out[2] = "WBMP" | |
45 when "image/x-xpixmap" | |
46 out[2] = "XPM" | |
47 end | |
48 out[3] = "height=\"#{image.rows}\" width=\"#{image.columns}\"" | |
49 out['mime'] = image.mime_type | |
50 | |
51 # This needs work to cover more situations | |
52 # I can't see how to just list the number of channels with ImageMagick / rmagick | |
53 if image.colorspace.to_s == "CMYKColorspace" | |
54 out['channels'] = 4 | |
55 elsif image.colorspace.to_s == "RGBColorspace" | |
56 out['channels'] = 3 | |
57 end | |
58 | |
59 out['bits'] = image.channel_depth | |
60 | |
61 out | |
62 end | |
63 | |
64 end |