Example #1
0
                    $imageoriginal = imagecreatefromjpeg($src);
                    imagecopyresampled($thumb, $imageoriginal, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
                    $name = 'picture' . $i . '-' . $width . '-' . $height . '.jpg';
                    imagejpeg($thumb, $name, 100);
                    break;
                case 3:
                    $i++;
                    $imageoriginal = imagecreatefrompng($src);
                    imagecopyresampled($thumb, $imageoriginal, 0, 0, 0, 0, $width, $height, $image_info[0], $image_info[1]);
                    $name = 'picture' . $i . '-' . $width . '-' . $height . '.png';
                    imagepng($thumb, $name, 0);
                    break;
                default:
                    $j++;
                    break;
            }
            $image->removeAttribute('width');
            $image->removeAttribute('height');
            $image->setAttribute('src', $name);
        } else {
            $j++;
        }
    }
    $dom->saveHTMLfile('index.html');
    echo "zostało utworzono " . $i . " miniaturek obrazków<br/>";
    if ($j > 0) {
        echo "zostało pominiono " . $j . " obrazków";
    }
}
?>
</html>
Example #2
0
function save_html_str_to_file($if, $str)
{
    $dom = new DOMDocument();
    $dom->loadHTML($str);
    $dom->formatOutput = true;
    $dom->preserveWhitespace = true;
    $dom->saveHTMLfile($if);
}