/[pub]/suikawiki/script/misc/plugins/Image.wps
Suika

Diff of /suikawiki/script/misc/plugins/Image.wps

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by wakaba, Sat May 10 04:28:24 2003 UTC revision 1.2 by wakaba, Sat Jul 26 09:20:52 2003 UTC
# Line 4  FullName: Line 4  FullName:
4          SuikaWikiImage          SuikaWikiImage
5  URI:  URI:
6          IW:SuikaWiki:WikiAdmin          IW:SuikaWiki:WikiAdmin
7    Require:
8  # Require SuikaWiki::Plugin::SuikaWiki09          SuikaWiki::Plugin::SuikaWiki09 main SuikaWiki::Plugin::WikiPlugin
9    
10  {  {
11  Name:  Name:
# Line 89  Format: Line 89  Format:
89          if ($o->{magic} =~ m#image-type="([^"]+)"#) {          if ($o->{magic} =~ m#image-type="([^"]+)"#) {
90            my $type = $1; $type =~ tr/\x00-\x20\x7F//d;            my $type = $1; $type =~ tr/\x00-\x20\x7F//d;
91            $type =~ s/[^0-9A-Za-z_]/_/g;            $type =~ s/[^0-9A-Za-z_]/_/g;
92              if ($type eq 'image_png'
93               && $o->user_agent_names =~ m#Mozilla/[0-4]\.#) {
94                $type = 'image_jpeg';
95              }
96            my $uri = $o->uri('wiki'); my $epage = $o->encode($o->{page});            my $uri = $o->uri('wiki'); my $epage = $o->encode($o->{page});
97            my $alt = ''; $alt = $1 if $o->{magic} =~ /image-alt="([^"]+)"/;            my $alt = ''; $alt = $1 if $o->{magic} =~ /image-alt="([^"]+)"/;
98            $r = qq(<img src="$uri?mypage=$epage;mycmd=$type" alt="$alt" title="@{[$o->escape($o->{page})]}" longdesc="$uri?$epage" class="embed" />);            $r = qq(<img src="$uri?mypage=$epage;mycmd=$type" alt="$alt" title="@{[$o->escape($o->{page})]}" longdesc="$uri?$epage" class="embed" />);
# Line 144  MODULE: Line 148  MODULE:
148          };          };
149          $Type{'image/jpeg'} = {          $Type{'image/jpeg'} = {
150                  type    => 'image/jpeg',                  type    => 'image/jpeg',
151                  suffix  => 'jpeg',                  suffix  => 'jpg',
152          };          };
153          $Type{'image/j2k'} = {          $Type{'image/j2k'} = {
154                  type    => 'image/j2k',                  type    => 'image/j2k',
# Line 180  MODULE: Line 184  MODULE:
184            }            }
185            $page;            $page;
186          }          }
187            
188            $main::PathTo{convert} ||= 'convert';
189          sub convert_image_type ($$$$) {          sub convert_image_type ($$$$) {
190            my ($o, $r, $from => $to) = @_;            my ($o, $r, $from => $to) = @_;
191            $from ||= {}; $to ||= {};            $from ||= {}; $to ||= {};
192            if ($from->{type} && $to->{type}) {            if ($from->{type} && $to->{type}) {
193              my $fname = $o->_path_to ('TempPrefix').time.'.tmp.';              my $fname = $o->_path_to ('TempPrefix').time.'.tmp.';
194              open PNG, '>', $fname . $from->{suffix};          $fname = 'a.';
195                binmode PNG;              open ORG, '>', $fname . $from->{suffix};
196                print PNG $r;                binmode ORG; local $| = 1;
197              close PNG;                print ORG $r;
198              system ('convert', $fname . $from->{suffix} => $fname . $to->{suffix});              close ORG;undef $!;
199                system ($main::PathTo{convert}, $fname . $from->{suffix}
200                                             => $fname . $to->{suffix});
201              if ($fname . $to->{suffix}) {              if ($fname . $to->{suffix}) {
202                open ICO, $fname . $to->{suffix}; {                open NEW, $fname . $to->{suffix}; {
203                  binmode ICO;                  binmode NEW;
204                  local $/ = undef;                  local $/ = undef;
205                  $r = <ICO>;                  $r = <NEW>;
206                } close ICO;                } close NEW;
207              } else {              } else {
208                $r = '';                $r = '';
209              }              }
210              unlink $fname . $from->{suffix};              #unlink $fname . $from->{suffix};
211              unlink $fname . $to->{suffix};              #unlink $fname . $to->{suffix};
212            } else {            } else {
213              $r = '';              $r = '';
214            }            }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

admin@suikawiki.org
ViewVC Help
Powered by ViewVC 1.1.24