The requested changes are too big and content was truncated. Show full diff
@@ -1,64 +1,69 | |||
|
1 | 1 | # The MIT License |
|
2 | 2 | # |
|
3 | 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy |
|
4 | 4 | # of this software and associated documentation files (the "Software"), to deal |
|
5 | 5 | # in the Software without restriction, including without limitation the rights |
|
6 | 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
7 | 7 | # copies of the Software, and to permit persons to whom the Software is |
|
8 | 8 | # furnished to do so, subject to the following conditions: |
|
9 | 9 | # |
|
10 | 10 | # The above copyright notice and this permission notice shall be included in |
|
11 | 11 | # all copies or substantial portions of the Software. |
|
12 | 12 | # |
|
13 | 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
14 | 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
15 | 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
16 | 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
17 | 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
18 | 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
|
19 | 19 | # THE SOFTWARE. |
|
20 | 20 | # |
|
21 | 21 | # This implements native php methods used by tcpdf, which have had to be |
|
22 | 22 | # reimplemented within Ruby. |
|
23 | 23 | |
|
24 | 24 | module RFPDF |
|
25 | 25 | |
|
26 | 26 | # http://uk2.php.net/getimagesize |
|
27 | 27 | def getimagesize(filename) |
|
28 | 28 | image = Magick::ImageList.new(filename) |
|
29 | 29 | |
|
30 | 30 | out = Hash.new |
|
31 | 31 | out[0] = image.columns |
|
32 | 32 | out[1] = image.rows |
|
33 | 33 | |
|
34 | 34 | # These are actually meant to return integer values But I couldn't seem to find anything saying what those values are. |
|
35 | 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 | 36 | case image.mime_type |
|
37 | 37 | when "image/gif" |
|
38 | 38 | out[2] = "GIF" |
|
39 | 39 | when "image/jpeg" |
|
40 | 40 | out[2] = "JPEG" |
|
41 | 41 | when "image/png" |
|
42 | 42 | out[2] = "PNG" |
|
43 | 43 | when " image/vnd.wap.wbmp" |
|
44 | 44 | out[2] = "WBMP" |
|
45 | 45 | when "image/x-xpixmap" |
|
46 | 46 | out[2] = "XPM" |
|
47 | 47 | end |
|
48 | 48 | out[3] = "height=\"#{image.rows}\" width=\"#{image.columns}\"" |
|
49 | 49 | out['mime'] = image.mime_type |
|
50 | 50 | |
|
51 | 51 | # This needs work to cover more situations |
|
52 | 52 | # I can't see how to just list the number of channels with ImageMagick / rmagick |
|
53 | 53 | if image.colorspace.to_s == "CMYKColorspace" |
|
54 | 54 | out['channels'] = 4 |
|
55 | 55 | elsif image.colorspace.to_s == "RGBColorspace" |
|
56 | 56 | out['channels'] = 3 |
|
57 | 57 | end |
|
58 | 58 | |
|
59 | 59 | out['bits'] = image.channel_depth |
|
60 | File.open( TCPDF.k_path_cache + File::basename(filename), 'w'){|f| | |
|
61 | f.binmode | |
|
62 | f.print image.to_blob | |
|
63 | f.close | |
|
64 | } | |
|
60 | 65 | |
|
61 | 66 | out |
|
62 | 67 | end |
|
63 | 68 | |
|
64 | 69 | end |
|
1 | NO CONTENT: modified file | |
The requested commit or file is too big and content was truncated. Show full diff |
General Comments 0
You need to be logged in to leave comments.
Login now