Fatal error: Call to undefined function iconv_get_encoding()
macのiconv関連php拡張が入ってないみたい。
インストール
$ sudo port install php5-iconv
これでOK。
基本的には技術メモです。
Fatal error: Call to undefined function iconv_get_encoding()
$ sudo port install php5-iconv
$ ./youtube-dl.py http://www.youtube.com/watch?v=********* -lとyoutubeのビデオURLを渡すだけ。-lオプションを付けてるのは、つけないとデフォルトのflvファイル名が英数字の羅列になっちゃうので。-lを付ければ名前もちゃんとつけてくれます(日本語OK)。
$ ./youtube-dl.py -h
Usage: youtube-dl.py [options] url...
Options:
-h, --help print this help text and exit
-v, --version print program version and exit
-U, --update update this program to latest stable version
-i, --ignore-errors continue on download errors
-r LIMIT, --rate-limit=LIMIT
download rate limit (e.g. 50k or 44.6m)
-R RETRIES, --retries=RETRIES
number of retries (default is 10)
--playlist-start=NUMBER
playlist video to start at (default is 1)
--playlist-end=NUMBER
playlist video to end at (default is last)
--dump-user-agent display the current browser identification
Authentication Options:
-u USERNAME, --username=USERNAME
account username
-p PASSWORD, --password=PASSWORD
account password
-n, --netrc use .netrc authentication data
Video Format Options:
-f FORMAT, --format=FORMAT
video format code
--all-formats download all available video formats
--max-quality=FORMAT
highest quality format to download
Verbosity / Simulation Options:
-q, --quiet activates quiet mode
-s, --simulate do not download video
-g, --get-url simulate, quiet but print URL
-e, --get-title simulate, quiet but print title
--get-thumbnail simulate, quiet but print thumbnail URL
--get-description simulate, quiet but print video description
--get-filename simulate, quiet but print output filename
--no-progress do not print progress bar
--console-title display progress in console titlebar
Filesystem Options:
-t, --title use title in file name
-l, --literal use literal title in file name
-A, --auto-number number downloaded files starting from 00000
-o TEMPLATE, --output=TEMPLATE
output filename template
-a FILE, --batch-file=FILE
file containing URLs to download ('-' for stdin)
-w, --no-overwrites
do not overwrite files
-c, --continue resume partially downloaded files
--cookies=FILE file to dump cookie jar to
--no-part do not use .part files
--no-mtime do not use the Last-modified header to set the file
modification time
<?php
// 正方形に切り取る
$im = new Imagick();
$im->readImage('/home/kasahi/tmp/org.jpg');
$im->cropThumbnailImage(80, 80);
$im->writeImage('/home/kasahi/tmp/resize.jpg');
$im->destroy();
?>
<?php
// 余りの背景を白でうめて正方形にする場合
$im = new Imagick();
$im->readImage('/home/kasahi/tmp/org.jpg');
$sideNum = 300; // 一辺を300ピクセルにする
$im->setImageBackgroundColor(new ImagickPixel('white'));
if ($im->getImageWidth() > $im->getImageHeight()) {
$im->scaleImage($sideNum, 0);
$height = ($sideNum - $im->getImageHeight()) / 2;
$im->spliceImage(0, $height, 0, 0);
$im->spliceImage(0, $sideNum - $im->getImageHeight(), 0, $im->getImageHeight());
} else {
$im->scaleImage(0, $sideNum);
$width = ($sideNum - $im->getImageWidth()) / 2;
$im->spliceImage($width, 0, 0, 0);
$im->spliceImage($sideNum - $im->getImageWidth(), 0, $im->getImageWidth(), 0);
}
$im->writeImage('/home/kasahi/tmp/resize.jpg');
$im->destroy();
?>
$ php imagik_test.php zsh: segmentation fault php imagik_test.phpとかsegmentation faultを起こすようになってしまった。
$ ./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp $ make $ sudo make installこのオプションでコンパイルしてたので先人に習ってそのままやって見る。
$ convert -v Version: ImageMagick 6.2.8 08/28/09 Q16 file:/usr/share/ImageMagick-6.2.8/doc/index.html Copyright: Copyright (C) 1999-2006 ImageMagick Studio LLCで6.2.8だった。
$ sudo yum remove ImageMagick
$ wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
$ tar zxvf ImageMagick.tar.gz $ cd ImageMagick-6.6.7-7 $ ./configure --disable-static --with-modules --without-perl --without-magick-plus-plus --with-quantum-depth=8 --disable-openmp $ make $ sudo make install※configureのオプションに関しては↑を付けておいたほうがよさげ。
$ convert -v Version: ImageMagick 6.6.7-7 2011-02-15 Q16 http://www.imagemagick.org Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLCOK。
$ sudo pecl uninstall imagick
$ sudo pecl install imagick
$ sudo /etc/init.d/httpd restart
$ sudo pecl install imagick ------------ .....................done: 93,920 bytes 13 source files, building running: phpize sh: phpize: command not foundERROR: `phpize' failed ------------と言われる。phpizeがないみたい。
$ yum -y install php-develを入れる。
$ sudo pecl install imagick ------------ .....................done: 93,920 bytes checking whether to enable the imagick GraphicsMagick backend... no checking ImageMagick MagickWand API configuration program... configure: error: not found. Please provide a path to MagickWand-config or Wand-config pr ogram. ERROR: `/var/tmp/imagick/configure --with-imagick' failed ------------
$ sudo yum -y install ImageMagick-devel ------------ .......... Installed: ImageMagick-devel.x86_64 0:6.2.8.0-4.1 Dependency Installed: ghostscript-devel.x86_64 0:8.15.2-9.12.el5_5 lcms-devel.x86_64 0:1.18-0.1.beta1.el5_3.2 libICE-devel.x86_64 0:1.0.1-2.1 libSM-devel.x86_64 0:1.0.1-3.1 libXext-devel.x86_64 0:1.0.1-2.1 libXt-devel.x86_64 0:1.0.2-3.2.el5 Dependency Updated: ghostscript.x86_64 0:8.15.2-9.12.el5_5 Complete! ------------
$ sudo pecl install imagick ------------ ........ Build process completed successfully Installing '/usr/lib64/php/modules/imagick.so' Installing '/usr/include/php/ext/imagick/php_imagick_defs.h' Installing '/usr/include/php/ext/imagick/php_imagick_shared.h' Installing '/usr/include/php/ext/imagick/php_imagick.h' install ok: channel://pecl.php.net/imagick-3.0.1configuration option "php_ini" is not set to php.ini location You should add "extension=imagick.so" to php.ini ------------
$ sudo vim /etc/php.d/imagick.iniimagick.ini
extension=imagick.so