imageflow met youtube

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Java developer met testervaring

Java developer met testervaring Functieomschrijving "De drempel tussen de burger en de Belastingdienst zo laag mogelijk houden: dat is de belangrijke taak van ons team. Dit doen we door het burgerportaal Mijn Belastingdienst continu te verbeteren." René, Java-specialist bij de Belastingdienst. De keten Interactie is een samenwerkingsverband van alle dienstonderdelen binnen de Belastingdienst. Samen zorgen we dat het contact met burgers en bedrijven goed kan plaatsvinden. Onze belangrijkste opgave? Zoveel mogelijk digitaliseren. Dat doen we binnen het onderdeel Informatievoorzieningen (IV), de ICT-organisatie van de Belastingdienst. Denk bij de producten die IV-Interactie ontwikkelt en onderhoudt aan portalen, formulieren en authenticatie- en

Bekijk vacature »

Ceasar Feijen

Ceasar Feijen

31/07/2008 13:47:00
Quote Anchor link
Hai iedereen die niet met vakantie is
Ik heb een nieuw grapje gemaakt met imageflow en de nieuwe youtube API
vb. http://www.cfcms.nl/imageflowyoutube/

gebaseerd op deze http://194.95.111.244/~countzero/scripts/_myImageFlow/

Nu zit hier een reflect.php bestand bij die zorgt voor die reflectie bij die plaatjes.
Nu wil ik dit uiteraard ook bij mijn youtube versie. Wie verveelt zich en kan het script aanpassen zodat het externe plaatjes kan inlezen zoals bijv. http://img.youtube.com/vi/9hiCyRnSXM4/0.jpg zodat je dit kunt doen reflect.php?img=http://img.youtube.com/vi/9hiCyRnSXM4/0.jpg met parameters voor de afmetingen ect. ( eventueel ook cachen en beveiligen zodat het niet misbruikt wordt )

De tool stel ik uiteraard weer beschikbaar aan de community en in dit geval aan Finn de maker van imageflow
Ik kan evt. de hele tool opsturen per mail

Hier de code van reflect.php
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
<?php
    /*
        ----------------------------------------------------------------
        Easy Reflections by Richard Davey, Core PHP (rich@corephp.co.uk)
        v2 - 2nd March 2007
        Updates include changes by Monte Ohrt (monte@ohrt.com)
        ----------------------------------------------------------------
        You are free to use this in any product, or on any web site.
        Latest builds at: http://reflection.corephp.co.uk
        ----------------------------------------------------------------

        This script accepts the following $_GET parameters:

        img                required    The source image (to reflect)
        height            optional    Height of the reflection (% or pixel value)
        bgc                optional    Background colour to fade into, default = #000000
        fade_start      optional    Start the alpha fade from whch value? (% value)
        fade_end        optional    End the alpha fade from whch value? (% value)
        jpeg            optional    Output will be JPEG at 'param' quality (default 80)
        cache           optional    Save reflection image to the cache? (boolean)
    */

    // Replace special chars to be HTML-Code

    function stringToHTML($string)
    {

        $array_search = array('é', 'è', 'ë', 'ê', 'à', 'ä', 'Ä', 'â', 'ù', 'ü', 'Ü', 'û', 'ö', 'Ö', 'ô', 'ï', 'î');
        $array_replace = array('&eacute;', '&egrave;',    '&euml;', '&ecirc;', '&agrave;', '&auml;', '&Auml;', '&acirc;', '&ugrave;', '&uuml;', '&Uuml;', '&ucirc;', '&ouml;', '&Ouml;', '&ocirc;', '&iuml;', '&icirc;');
        $string_return = str_replace($array_search, $array_replace, $string);
        return $string_return;
    }


    // CACHE! EVERYTHING!
    $_GET['cache'] = 1;

    //    PHP Version sanity check
    if (version_compare('4.3.2', phpversion()) == 1)
    {

        echo 'This version of PHP is not fully supported. You need 4.3.2 or above.';
        exit();
    }


    //    GD check
    if (extension_loaded('gd') == false && !dl('gd.so'))
    {

        echo 'You are missing the GD extension for PHP, sorry but I cannot continue.';
        exit();
    }


    //    Our allowed query string parameters

    //  To cache or not to cache? that is the question

    if (isset($_GET['cache']))
    {

        if ((int) $_GET['cache'] == 1)
        {

            $cache = true;
        }

        else
        {
            $cache = false;
        }
    }

    else
    {
        $cache = false;
    }


    //    img (the image to reflect)
    if (isset($_GET['img']))
    {

        $source_image = $_GET['img'];

        //$source_image = utf8_decode($source_image);

        $source_image = str_replace('://','',$source_image);
        //$source_image = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . $source_image;

        if (file_exists($source_image))
        {

            if ($cache)
            {

                $cache_dir = dirname($source_image);
                $cache_base = basename($source_image);
                $cache_file = 'refl_' . md5($_SERVER['REQUEST_URI']) . '_' . $cache_base;
                $cache_path = $cache_dir . DIRECTORY_SEPARATOR . $cache_file;

                if (file_exists($cache_path) && filemtime($cache_path) >= filemtime($source_image))
                {

                    // Use cached image
                    $image_info = getimagesize($cache_path);
                    header("Content-type: " . $image_info['mime']);
                    readfile($cache_path);
                    exit();
                }
            }
        }

        else
        {
          echo 'Cannot find or read source image';
          exit();
        }
    }

    else
    {
        echo 'No source image to reflect supplied';
        exit();
    }


    //    bgc (the background colour used, defaults to black if not given)
    if (isset($_GET['bgc']) == false)
    {

        $red = 0;
        $green = 0;
        $blue = 0;
    }

    else
    {
        //    Extract the hex colour
        $hex_bgc = $_GET['bgc'];

        //    Does it start with a hash? If so then strip it
        $hex_bgc = str_replace('#', '', $hex_bgc);

        switch (strlen($hex_bgc))
        {
            case
6:
                $red = hexdec(substr($hex_bgc, 0, 2));
                $green = hexdec(substr($hex_bgc, 2, 2));
                $blue = hexdec(substr($hex_bgc, 4, 2));
                break;

            case
3:
                $red = substr($hex_bgc, 0, 1);
                $green = substr($hex_bgc, 1, 1);
                $blue = substr($hex_bgc, 2, 1);
                $red = hexdec($red . $red);
                $green = hexdec($green . $green);
                $blue = hexdec($blue . $blue);
                break;

            default:

                //    Wrong values passed, default to black
                $red = 0;
                $green = 0;
                $blue = 0;
        }
    }


    //    height (how tall should the reflection be?)
    if (isset($_GET['height']))
    {

        $output_height = $_GET['height'];

        //    Have they given us a percentage?
        if (substr($output_height, -1) == '%')
        {

            //    Yes, remove the % sign
            $output_height = (int) substr($output_height, 0, -1);

            //    Gotta love auto type casting ;)
            if ($output_height < 10)
            {

                $output_height = "0.0$output_height";
            }

            else
            {
                $output_height = "0.$output_height";
            }
        }

        else
        {
            $output_height = (int) $output_height;
        }
    }

    else
    {
        //    No height was given, so default to 50% of the source images height
        $output_height = 0.50;
    }


    if (isset($_GET['fade_start']))
    {

        if (strpos($_GET['fade_start'], '%') !== false)
        {

            $alpha_start = str_replace('%', '', $_GET['fade_start']);
            $alpha_start = (int) (127 * $alpha_start / 100);
        }

        else
        {
            $alpha_start = (int) $_GET['fade_start'];

            if ($alpha_start < 1 || $alpha_start > 127)
            {

                $alpha_start = 80;
            }
        }
    }

    else
    {
        $alpha_start = 80;
    }


    if (isset($_GET['fade_end']))
    {

        if (strpos($_GET['fade_end'], '%') !== false)
        {

            $alpha_end = str_replace('%', '', $_GET['fade_end']);
            $alpha_end = (int) (127 * $alpha_end / 100);
        }

        else
        {
            $alpha_end = (int) $_GET['fade_end'];

            if ($alpha_end < 1 || $alpha_end > 0)
            {

                $alpha_end = 0;
            }
        }
    }

    else
    {
        $alpha_end = 0;
    }


    /*
        ----------------------------------------------------------------
        Ok, let's do it ...
        ----------------------------------------------------------------
    */

    //    How big is the image?

    $image_details = getimagesize($source_image);

    if ($image_details === false)
    {

        echo 'Not a valid image supplied, or this script does not have permissions to access it.';
        exit();
    }

    else
    {
        $width = $image_details[0];
        $height = $image_details[1];
        $type = $image_details[2];
        $mime = $image_details['mime'];
    }


    //    Calculate the height of the output image
    if ($output_height < 1)
    {

        //    The output height is a percentage
        $new_height = $height * $output_height;
    }

    else
    {
        //    The output height is a fixed pixel value
        $new_height = $output_height;
    }


    //    Detect the source image format - only GIF, JPEG and PNG are supported. If you need more, extend this yourself.
    switch ($type)
    {
        case
1:
            //    GIF
            $source = imagecreatefromgif($source_image);
            break;

        case
2:
            //    JPG
            $source = imagecreatefromjpeg($source_image);
            break;

        case
3:
            //    PNG
            $source = imagecreatefrompng($source_image);
            break;

        default:

            echo 'Unsupported image file format.';
            exit();
    }



    /*
        ----------------------------------------------------------------
        Build the reflection image
        ----------------------------------------------------------------
    */

    //    We'll store the final reflection in $output. $buffer is for internal use.

    $output = imagecreatetruecolor($width, $new_height);
    $buffer = imagecreatetruecolor($width, $new_height);

    //    Copy the bottom-most part of the source image into the output
    imagecopy($output, $source, 0, 0, 0, $height - $new_height, $width, $new_height);

    //    Rotate and flip it (strip flip method)
    for ($y = 0; $y < $new_height; $y++)
    {

       imagecopy($buffer, $output, 0, $y, 0, $new_height - $y - 1, $width, 1);
    }


    $output = $buffer;

    /*
        ----------------------------------------------------------------
        Apply the fade effect
        ----------------------------------------------------------------
    */

    //    This is quite simple really. There are 127 available levels of alpha, so we just
    //    step-through the reflected image, drawing a box over the top, with a set alpha level.
    //    The end result? A cool fade into the background colour given.

    //    There are a maximum of 127 alpha fade steps we can use, so work out the alpha step rate


    $alpha_length = abs($alpha_start - $alpha_end);

    for ($y = 0; $y <= $new_height; $y++)
    {

        //  Get % of reflection height
        $pct = $y / $new_height;

        //  Get % of alpha
        if ($alpha_start > $alpha_end)
        {

            $alpha = (int) ($alpha_start - ($pct * $alpha_length));
        }

        else
        {
            $alpha = (int) ($alpha_start + ($pct * $alpha_length));
        }


        imagefilledrectangle($output, 0, $y, $width, $y, imagecolorallocatealpha($output, $red, $green, $blue, $alpha));

    }



    /*
        ----------------------------------------------------------------
        HACK - Build the reflection image by combining the source
        image AND the reflection in one new image!
        ----------------------------------------------------------------
    */

        $finaloutput = imagecreatetruecolor($width, $height+$new_height);
        imagecopy($finaloutput, $source, 0, 0, 0, 0, $width, $height);
        imagecopy($finaloutput, $output, 0, $height, 0, 0, $width, $new_height);
        $output = $finaloutput;

    /*
        ----------------------------------------------------------------
        Output our final PNG
        ----------------------------------------------------------------
    */


    if (headers_sent())
    {

        echo 'Headers already sent, I cannot display an image now. Have you got an extra line-feed in this file somewhere?';
        exit();
    }

    else
    {
        //    If you'd rather output a JPEG instead of a PNG then pass the parameter 'jpeg' (no value needed) on the querystring

        if (isset($_GET['png']))
        {

            //    PNG
            header("Content-type: image/png");
            imagepng($output);

            // Save cached file
            if ($cache)
            {

                imagepng($output, $cache_path);
            }

        }

        else
        {
            if(!isset( $_GET['jpeg']))  $_GET['jpeg'] = 90;

            $quality = (int) $_GET['jpeg'];

            if ($quality < 1 || $quality > 100)
            {

                $quality = 90;
            }


            //    JPEG (the final parameter = the quality, 0 = terrible, 100 = pixel perfect)
            header("Content-type: image/jpeg");
            imagejpeg($output, '', $quality);

            // Save cached file
            if ($cache)
            {

                imagejpeg($output, $cache_path, $quality);
            }


        }


        imagedestroy($output);
        exit();
    }

?>
Gewijzigd op 01/01/1970 01:00:00 door Ceasar Feijen
 
PHP hulp

PHP hulp

17/10/2021 01:52:53
 
Ceasar Feijen

Ceasar Feijen

31/07/2008 19:12:00
Quote Anchor link
Okay. opgelost met file_get_contents, hierna de plaatjes wegzetten in een directory die vervolgens wordt uitgelezen door reflect.php
 
Ceasar Feijen

Ceasar Feijen

05/09/2008 23:16:00
Quote Anchor link
Voor de geintereseerde mensen de app is klaar en is gratis te downloaden.
Werkt nu met Youtube en Dailymotion
http://www.imageflow.nl/

nb. Dit was voor mij gewoon een hobby trajektje om de SEO te testen met content van youtube.
Gewijzigd op 01/01/1970 01:00:00 door Ceasar Feijen
 



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.