自動バナー作成の日本語対応
■ このスレッドは過去ログ倉庫に格納されています
0001どん
02/03/18 02:39ID:YhGXqOEg自動バナー作成スクリプトを作りましたが 半角英数には対応しますが
日本語を入力すると文字化けしてしまいます。
どなかた申し訳有りませんが 改善策をご指導くださいませ。
0003どん
02/03/18 02:51ID:YhGXqOEgfontは日本語用にmsgothic.ttfを "/usr/share/fonts"に放り込んで
"arial"から変更してトライしています。
すみませんが 宜しくお願いします。
使用サーバーは 米国のレンタルサーバーでLinux 7.1がのっています。
=========================================================
#! /usr/bin/perl -w
use Mysql;
require 'util.pl';
require 'function.pl';
use CGI;
use Image::Magick;
#print "Content-type: text/html\n\n";
$dbh=&dbconnect;
$fnd="false";
%qs=&util'div_qs;
0004どん
02/03/18 02:51ID:YhGXqOEguse constant FONTS_DIR => "/usr/share/fonts";
my $advtext="test";
my $q = new CGI;
my $font = $q->param( "font" ) || 'arial';
my $size = $q->param( "size" ) || 20;
#my $string = $q->param( "text" ) || 'Hello';
my $color = $q->param( "color" ) || 'black';
#my $font="arial";
#my $size="20";
my $string=$advtext;
#my $color="blue";
my $textlen=length($string);
$font =~ s/\W//g;
#print"font $font";
$font = 'cetus' unless -e FONTS_DIR . "/$font.ttf";
my $width=$textlen*12;
my $height=30;
my $image = new Image::Magick( size => $width.'x'.$height );
#my $image = new Image::Magick( size => '500x100' );
0005どん
02/03/18 02:51ID:YhGXqOEg# $colorset="transparent";
if($colorset eq "transparent")
{
#$image->Read('xc:white');
#$image->Transparent(color=>'');
$image->Read('xc:none');
}else
{
$image->Read('xc:'.$colorset);
}
$image->Annotate( font => "\@@{[ FONTS_DIR ]}/$font.ttf",
pen => $color,
pointsize => $size,
gravity => 'Center',
text => $string
);
binmode STDOUT;
print $q->header( "image/gif" );
$image->Write( "gif:-" );
0006どん
02/03/18 02:52ID:YhGXqOEg0007nobodyさん
02/03/18 10:23ID:???放置。
0008nobodyさん
02/03/18 13:19ID:???他のCGIとだいぶ違うからいいんでないの。
ImageMagick&Fontの偉い人たのむ。
0009nobodyさん
02/03/18 21:26ID:???}
■ このスレッドは過去ログ倉庫に格納されています