Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions

resource_random_jpg()

Parameters

ColumnTypeDefaultDescription
$resource
$width
$height

Location

include/test_functions.php lines 3 to 21

Definition

 
function resource_random_jpg($resource,$width$height)
    {
    
// Set random colours 
    
$bg_r =  mt_rand(0,255);
    
$bg_g mt_rand(0,255);
    
$bg_b mt_rand(0,255);

    
// Create image
    
$test_image imagecreate($width$height);
    
$text_r $bg_r 128 $bg_r 100 $bg_r 100;
    
$text_g $bg_g 128 $bg_g 100 $bg_g 100;
    
$text_b $bg_b 128 $bg_b 100 $bg_b 100;
    
$text_col imagecolorallocate($test_image$text_r$text_g$text_b);
    
imagestring($test_image52015,  'Image ' $resource$text_col);

    
$path get_resource_path($resource,true,'',true,'jpg');
    
imagejpeg($test_image$path,50);
    
create_previews($resource,false,'jpg');
    }

This article was last updated 27th April 2024 10:05 Europe/London time based on the source file dated 4th April 2024 10:05 Europe/London time.