Created
February 12, 2010 09:30
-
-
Save clairvy/302434 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| debug.log | |
| Osaka.ttf |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| AddHandler cgi-script .cgi | |
| Options +ExecCGI |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/opt/local/bin/perl | |
| # -*- mode: perl; coding: utf-8-unix; -*- | |
| #use strict; | |
| #use warnings; | |
| use FindBin; | |
| use lib ("$FindBin::RealBin/perl5/lib/perl5", "$FindBin::RealBin/perl5/lib/perl5/darwin-2level"); | |
| use Image::Magick; | |
| use Encode; | |
| use CGI; | |
| open(OUT, ">> debug.log"); | |
| print(OUT "START"); | |
| close(OUT); | |
| #メッセージを出力のパラメーター | |
| #文字サイズ | |
| $psize = "18"; | |
| #文字サイズ:黒 | |
| $fill = "#000000"; | |
| #文字エンコード | |
| $enc = "utf8"; | |
| # フォントの指定 | |
| $font = "Osaka.ttf"; # Mac OS X のフォント | |
| # 画像を指定 | |
| $file = "1.jpg"; | |
| my $image = makeImage(); | |
| # 画像出力 | |
| my $fname = 'aaa.jpg'; | |
| print(CGI->header( | |
| -type => 'image/jpeg', | |
| -attachment => $fname, | |
| )); | |
| binmode STDOUT; | |
| $image->Write('jpeg:-'); | |
| undef $image; | |
| exit; | |
| sub makeImage { | |
| $text1 = "テスト"; | |
| # UTF-8へ変換 | |
| # $text1 = decode('utf8', $text1); | |
| # オブジェクト作成 | |
| $image = Image::Magick->new; | |
| # 画像読み込み | |
| $image->Read($file); | |
| $image->Minify(); | |
| # 文字を記入する | |
| #名前 | |
| $image->Annotate(text=>$text1,x=>60, y=>330, fill=>$fill, pointsize=>$psize, encoding=>$enc, font=>$font ); | |
| return $image; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <body> | |
| <h1>画像を作るCGI からのリンク</h1> | |
| <img src="gazou.cgi" alt="失敗した?"/> | |
| </body> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/opt/local/bin/perl | |
| use strict; | |
| use warnings; | |
| use FindBin; | |
| use lib ("$FindBin::RealBin/perl5/lib/perl5", "$FindBin::RealBin/perl5/lib/perl5/darwin-2level"); | |
| use GD; | |
| { | |
| my $im = GD::Image->new(250, 800); | |
| my $white = $im->colorAllocate(255, 255, 255); | |
| my $gray = $im->colorAllocate(200, 200, 200); | |
| $im->fill(0, 0, $gray); | |
| $im->interlaced('true'); | |
| my $fname = '1.jpg'; | |
| open(my $fh, '>', $fname) or die; | |
| binmode $fh; | |
| print {$fh} $im->jpeg; | |
| close($fh); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/opt/local/bin/perl | |
| use strict; | |
| use warnings; | |
| use Image::Magick; | |
| my $image = Image::Magick->new(); | |
| my $fname = "1.jpg"; | |
| $image->Read($fname); | |
| $image->Write("jpeg:-"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
