phpのGDで画像のサイズを変更させる処理をさせていたらエラーが発生!

Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 12800 bytes)
ってエラーに悩まされました。サーバーのメモリーが足りない感じガーン

3000px とか大きいサイズの写真を使うとエラーがでるみたい。
解決策としては、phpで ini_set('memory_limit', '512M'); って書けばOKでした。
ini_set('memory_limit', '-1'); にすると制限なしになるがキケンなあせる感じ

他の回避方法としては、PHP で大きいJPEGやPNGファイルをPHPで扱うときのメモリエラー回避方法に載ってました。

function setMemoryForImage( $filename ){
$imageInfo = getimagesize($filename);
$MB = 1048576; // number of bytes in 1M
$K64 = 65536; // number of bytes in 64K
$TWEAKFACTOR = 1.5; // Or whatever works for you
$memoryNeeded = round( ( $imageInfo[0] * $imageInfo[1]
* $imageInfo['bits']
* $imageInfo['channels'] / 8
+ $K64
) * $TWEAKFACTOR
);
//ini_get('memory_limit') only works if compiled with "--enable-memory-limit" also
//Default memory limit is 8MB so well stick with that.
//To find out what yours is, view your php.ini file.
$memoryLimit = 8 * $MB;

if (function_exists('memory_get_usage') &&
memory_get_usage() + $memoryNeeded > $memoryLimit)
{
$newLimit = $memoryLimitMB + ceil( ( memory_get_usage()
+ $memoryNeeded
- $memoryLimit
) / $MB
);
ini_set( 'memory_limit', $newLimit . 'M' );
return true;
}else
return false;
}
}


ちょっと知るのが遅って感じですけど、カヤックさんのソースを見てたら
メタタグに X-UA-Compatible っていう見たことがない指定があったので
調べたらIE8のレンダリングモードを指定するものらしいです。

これはメモですねひらめき電球

IE8のレンダリングモードに関するまとめ

// IE8標準準拠モードを指定
<meta http-equiv="X-UA-Compatible" content="IE=8">

// IE7標準準拠モードを指定
<meta http-equiv="X-UA-Compatible" content="IE=7">

// Quirksモードを指定
<meta http-equiv="X-UA-Compatible" content="IE=5">

// 最新の標準準拠モードを指定 (IE8の場合はIE8標準準拠モード)
<meta http-equiv="X-UA-Compatible" content="IE=edge">

// 複数を指定した場合は最新の標準準拠モードを用いる
// (この場合はIE8標準準拠モードになる)
<meta http-equiv="X-UA-Compatible" content="IE=5; IE=7; IE=8">


ちなみにこの機能を知ったカヤックさんのソースはこうなってました。
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" />

勉強になりました。ありがとうございます。
コリスさんのブログにCSSのハック集が紹介されていたのでメモひらめき電球
主要ブラウザの特定ブラウザのみに有効なCSSハック集

元ネタのサイトです。英語になってます。
Documenting the Hacks: CSS Browser Targeting


特定のブラウザのみに有効にする方法はけっこう知らなかったので
今後使わせてもらいますビックリマーク
特にクロームやFirefox2、Firefox3のみに使いたいときとか便利ですね。

自分用に一部引用です。
Safari 3.1 and Google Chromeのみ有効
body:nth-of-type(1) #selector {
property: value;
}


Firefox2のみ有効
#selector, x:-moz-any-link {
property: value;
}


Firefox3のみ有効
/* Target Firefox 2 */
#selector, x:-moz-any-link {
property: value;
}

/* Then overwrite for Firefox 3 specifically */
#selector, x:-moz-any-link, x:default {
property: value;
}