From: Bassel S. <bas...@gm...> - 2008-06-29 23:25:00
|
Hello folks, as you know ccHost can't make thumbnails from png files and it can't also convert svg files to png, as the result from discussions on #cc and openclipart.org malling list, we came to a solution to use inkscape to convert the files and gd to thumbnail them, so I wrote a simple php script that can be included later in ccHost to make the thumbnails part happen, Kindly Roan Horning sent me a script he wrote earlier for this and it helped me a lot to understand the structure of ccHost and how to make a class that can communicate with it, but for now I didn't followed the guidelines that Roan used in his class, just want to make sure that the simple script will work first. I don't have access to test server yet, kindly rejon is working on it for me. so for now I've attached the source code which is svg.txt for you to test, here is a simple how to get it working: 1- download the attached svg.txt and rename it to svg.php 2- make a mysql database, call it svg_data or any thing else 3- create a table in it called svgfiles: CREATE TABLE IF NOT EXISTS `svgfiles` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `filename` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; this database is for testing only it has nothing to do with the actual converting but you have to have it ;) 4- make a folder and call it whatever you like but make sure that it have a permission of 0777 ( this folder will be used for uploading the svg files and storing the pngs and thumbs ) 5- open svg.php in a text editor and define the following vars: $path_to_inkscape = ""; please but the full path to inkscape, if you can run inkscape from terminal by just writing (inkscape ) then leave this empty, if you need to /usr/bin/inkscape then: $path_to_inkscape = "/usr/bin/"; and so on $svg_default_background = "ffffff"; if a svg file has no background what color to use? ( actually this is not working ;-) ) $images_path = ""; the full path to the folder with 0777 you created earlier, for example: /opt/www/svg_files_go_here $db_name = ""; previously created database name $db_user = ""; database username $db_pass = ""; database password that's it, and it should work fine, you'll be able to upload svg files and the script will convert them to png and create thumbnails for you. there is a function in the file called ( imageresize) this actually create the thumbs from the generated png file, for now it's based on gd, the max size of the generated thumb is defined on line 103 and it's 200 for now, you can change it to what ever you want... if this script worked for you I will complete it and make a class from it that can be easily shipped to ccHost, Thanks every body and have a nice day, Bassel Safadi |