<?php // Create a blank image and add some text $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 255, 255, 255); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); $file = dirname(__FILE__) . '/simpletext.png'; $file2 = dirname(__FILE__) . '/simpletext.wbmp'; // Save the image as 'simpletext.png' imagepng($im, $file); // Free up memory imagedestroy($im); png2wbmp($file, $file2, 20, 120, 9); png2wbmp($file, $file2, 20, 120, -1);
<?php $file = dirname(__FILE__) . '/simpletext.wbmp'; png2wbmp('', $file, 20, 120, 8); png2wbmp(null, $file, 20, 120, 8); png2wbmp(false, $file, 20, 120, 8); unlink(dirname(__FILE__) . '/simpletext.wbmp');
public function pngToWbmp(string $pngFile, string $wbmpFile, array $settings = NULL) : bool { if (is_file($pngFile)) { $height = isset($settings['height']) ? $settings['height'] : 0; $width = isset($settings['width']) ? $settings['width'] : 0; $threshold = isset($settings['threshold']) ? $settings['threshold'] : 0; return png2wbmp($pngFile, $wbmpFile, $height, $width, $threshold); } else { return false; } }
<?php // Create a blank image and add some text $im = imagecreatetruecolor(120, 20); $text_color = imagecolorallocate($im, 255, 255, 255); imagestring($im, 1, 5, 5, 'A Simple Text String', $text_color); $file = dirname(__FILE__) . '/simpletext.png'; // Save the image as 'simpletext.png' imagepng($im, $file); // Free up memory imagedestroy($im); png2wbmp($file, '', 20, 120, 8); png2wbmp($file, null, 20, 120, 8); png2wbmp($file, false, 20, 120, 8); unlink(dirname(__FILE__) . '/simpletext.png');
public function pngToWbmp($pngFile = '', $wbmpFile = '', $settings = array()) { if (is_file($pngFile) && is_string($wbmpFile)) { $height = isset($settings['height']) ? $settings['height'] : 0; $width = isset($settings['width']) ? $settings['width'] : 0; $threshold = isset($settings['threshold']) ? $settings['threshold'] : 0; return png2wbmp($pngFile, $wbmpFile, $height, $width, $threshold); } else { Error::set(lang('Error', 'fileParameter', '1.(jpegFile)')); Error::set(lang('Error', 'stringParameter', '2.(wbmpFile)')); return false; } }