class "thinking" that png i txt

See all posts Reply

class "thinking" that png i txt new!
by baambaam, 12 years, 6 months ago
In my script:

$foo = new upload("./upload/yt.png");
$foo->file_new_name_body    = $name;
$foo->image_resize          = true;
$foo->image_ratio_y         = true;
$foo->image_x               = $width-(2*35+2);
$foo->image_crop            = '-1 -1 -1 -1';
$foo->image_background_color= '#ffffff';
$foo->image_border          = '35 35 120 35';
$foo->image_border_color    = '#000000';
$foo->image_text            = $waterhome;
$foo->image_text_color      = $waterhomecolor;
$foo->image_text_font       = 2;
$foo->image_text_y          = -5;
$foo->image_watermark       = "./upload/tymczasowe/".$name.".jpg";
$foo->image_watermark_y     = -10;
$foo->image_convert         = 'jpg';
$foo->Process($folder);

here is my png before "transforming":
http://koko.securityhost.pl/upload/yt.png
here is after "transforming":
http://koko.securityhost.pl/upload/gotowe/2012/05/4fb29c6f6526e.txt

so u can see that new image haven't watermark and many images from GIMP have this problem.

When i was adding this:
$foo->allowed = array('image/jpeg','image/jpg','image/gif','image/png','image/bmp');

nothing happen becouse script thinking that my png is txt

any solution for me?Reply
Re: class "thinking" that png i txt new!
by colin, 12 years, 6 months ago
Can you copy here the log produced by the class?Reply
Re: class "thinking" that png i txt new!
by Jorge, 12 years, 4 months ago
I also agree that it is not good to be loading PHP for every style sheet. If you load one PHP page with two dynmiac' style sheets, that's 3 PHP calls for every loaded page, for every visitor. That will add up real quick if/when your website starts to pull traffic.The best thing to do is leave the stylesheets static. If you need to add dynmiac style information, include it in the actual web page in style tags.cigraphics is on the right track for re-generating static style sheets when changes are made to the website, but then you have to worry about browsers caching their CSS sheets because they are expected to be static. I know there are workarounds for that, but why worry about it? Just include any dynmiac content in the main web page.Reply
Re: class "thinking" that png i txt new!
by baambaam, 12 years, 6 months ago
with $foo->allowed = array('image/jpeg','image/jpg','image/gif','image/png','image/bmp');

system information
- class version : 0.31
- operating system : Linux
- PHP version : 5.2.17
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 64M (67108864 bytes)
- language : en_GB
source is a local file /home/tmp/phpGWFVUT
- local file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
PHP exec() function is disabled
- Checking MIME type with mime.magic file (mime_content_type())
MIME type detected as text/plain by mime_content_type()
- MIME validated as text/plain
source variables
- You can use all these before calling process()
file_src_name : phpGWFVUT
file_src_name_body : phpGWFVUT
file_src_name_ext :
file_src_pathname : /home/tmp/phpGWFVUT
file_src_mime : text/plain
file_src_size : 37833 (max= 67108864)
file_src_error : 0
process file to ./upload/gotowe/2012/05/
- file size OK
- file renamed as phpGWFVUT.txt!
- error: Incorrect type of file.


and without:
system information
- class version : 0.31
- operating system : Linux
- PHP version : 5.2.17
- GD version : 2.0.34
- supported image types : png jpg gif bmp
- open_basedir : no restriction
- upload_max_filesize : 64M (67108864 bytes)
- language : en_GB
source is a local file /home/tmp/php8TsHdL
- local file name OK
determining MIME type
- Checking MIME type with Fileinfo PECL extension
Fileinfo PECL extension not available
- Checking MIME type with UNIX file() command
PHP exec() function is disabled
- Checking MIME type with mime.magic file (mime_content_type())
MIME type detected as text/plain by mime_content_type()
- MIME validated as text/plain
source variables
- You can use all these before calling process()
file_src_name : php8TsHdL
file_src_name_body : php8TsHdL
file_src_name_ext :
file_src_pathname : /home/tmp/php8TsHdL
file_src_mime : text/plain
file_src_size : 37833 (max= 67108864)
file_src_error : 0
process file to ./upload/gotowe/2012/05/
- file size OK
- file renamed as php8TsHdL.txt!
- file mime OK : text/plain
- new file name body : 4fb2c7d655b72
- file name safe format
- destination variables
file_dst_path : ./upload/gotowe/2012/05/
file_dst_name_body : 4fb2c7d655b72
file_dst_name_ext : txt
- checking for auto_rename
- destination file details
file_dst_name : 4fb2c7d655b72.txt
file_dst_pathname : ./upload/gotowe/2012/05/4fb2c7d655b72.txt
- 4fb2c7d655b72.txt doesn't exist already
- no image processing wanted
- process OK
Reply
Re: class "thinking" that png i txt new!
by colin, 12 years, 6 months ago
You PHP instance is wrongly configured, the MIME types detection is incorrect. The function mime_content_type() bases its detection on the mime.magic file, you may want to check that. Note that this is now deprecated in favor of PECL FileInfo, which your sstem doesn't seem to have.Reply