トップページphp
9コメント3KB

自動バナー作成の日本語対応

■ このスレッドは過去ログ倉庫に格納されています
0001どん02/03/18 02:39ID:YhGXqOEg
こんにちわ。
自動バナー作成スクリプトを作りましたが 半角英数には対応しますが
日本語を入力すると文字化けしてしまいます。
どなかた申し訳有りませんが 改善策をご指導くださいませ。
0002nobodyさん02/03/18 02:41ID:???
>>1
スクリプト晒してみれば?
0003どん02/03/18 02:51ID:YhGXqOEg
早速のレス有難うございます。

fontは日本語用に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:YhGXqOEg


use 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="yellow";
# $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:YhGXqOEg
宜しくお願いします。
0007nobodyさん02/03/18 10:23ID:???
単発質問スレッドは禁止です。
放置。
0008nobodyさん02/03/18 13:19ID:???
CGIで画像扱うスレてないでしょ。
他のCGIとだいぶ違うからいいんでないの。

ImageMagick&Fontの偉い人たのむ。
0009nobodyさん02/03/18 21:26ID:???
死ね自己厨。

}
■ このスレッドは過去ログ倉庫に格納されています