Tag: resize

Fit Cufon texts to its container

Well, I ran into a situation that my design messed up when the cufon title width passed it’s container width, so I needed to lower the font-size automatically to make it fit into it’s container staying still an one-line title. And I wanted to share here. Here’s the function I wrote:

function Cufon_Fit_Title(element){
    var TotalWidth = 0;
        TotalWidth += $(this).width();
    if(TotalWidth > element.width()){
        return true;

And here’s the important part of it, because jQuery’s $(document).ready() function won’t work well with Cufon texts (insert it anywhere in your document body – and don’t forget to change the selector):


PHP Animated Gif Resizer

There are many sites that use avatars and sometimes they use animated GIF files. But when it comes to resizing them, it really becomes a pain when your server doesn’t support ImageMagick. So I decided to write an animated GIF resizer based on GD Library (Because GD doesn’t support it directly either.)

It works like this:

  1. Extract frames from GIF animations into a temporary folder.
  2. Resizes all the frames
  3. Combines them into one file

Using this class is really simple. Here is the code

include_once "gifresizer.php";
$gr = new gifresizer;
$gr->temp_dir = "frames"; //note that it doesn't end with a "/"

// $gr->temp_dir = {a folder with a write permission (777)}; // The temporary folder which frames will be extracted to.
// $gr->resize({file to be resized}, {new file to be created}, {new width}, {new height});

Here’s an example:


Original GIF file :

Resized Image:

Here you can download the class, documentation and examples.

PHPClasses.org class main page


Note: I’m expecting some feedback. Here or at phpclasses.org. Doesn’t matter. If you are using it, tell me how it works.

FCKEditor “Dialog Width” Correction in Firefox

FCKEditor scriptini kurup çalıştıranlar için ufak bir değişiklik gerekiyor.Scriptin resim ekleme, arama ve değiştirme diyalogları Firefox’ta boyu düzgün çıkıyor ama eni kısa geliyor ve değişmiyor. Bunun çözümü olarak aşağıdaki kod eksikliğini farkettim ve tamamlayayım dedim. Bu kodu kullanarak scripti düzeltebilirsiniz. Script klasörünün içindeki “editor/fckdialog.html” dosyasını bir metin editörüyle açın ve RefreshSize() fonksiyonunu aşağıdakiyle değiştirin.

In English : I think FCKEditor has some bug or missing code about this situation. When I insalled and checked the dialogs, every dialog looks cropped and you cannot resize it again. I needed to fix that and this is what I got.Just open “editor/fckdialog.html” and change the function RefreshSize() with this:


function RefreshSize()
if ( bAutoSize )
var oInnerDoc = document.getElementById('frmMain').contentWindow.document ;

var iFrameHeight ;
var iFrameWidth ;
if ( document.all ){
iFrameHeight = oInnerDoc.body.offsetHeight ;
iFrameWidth = oInnerDoc.body.offsetWidth ;
iFrameHeight = document.getElementById('frmMain').contentWindow.innerHeight ;
iFrameWidth = document.getElementById('frmMain').contentWindow.innerWidth ;

var iInnerHeight = oInnerDoc.body.scrollHeight ;
var iInnerWidth = oInnerDoc.body.scrollWidth ;
var iDiffh = iInnerHeight - iFrameHeight ;
var iDiffw = iInnerWidth - iFrameWidth ;

if ( iDiffh > 0 || iDiffw > 0 )
if ( document.all ){
window.dialogHeight = ( parseInt( window.dialogHeight ) + iDiffh ) + 'px' ;
window.dialogWidth = ( parseInt( window.dialogWidth ) + iDiffw ) + 'px' ;
window.resizeBy( iDiffw, iDiffh ) ;

Last.fm RPS

Follow me on Twitter

GiottoPress by Enrique Chavez