Projet

Général

Profil

Révision 6ff32cea

Ajouté par Florent Torregrosa il y a environ 9 ans

Update core to 7.36

Voir les différences:

drupal7/modules/system/image.gd.inc
229 229
function image_gd_load(stdClass $image) {
230 230
  $extension = str_replace('jpg', 'jpeg', $image->info['extension']);
231 231
  $function = 'imagecreatefrom' . $extension;
232
  return (function_exists($function) && $image->resource = $function($image->source));
232
  if (function_exists($function) && $image->resource = $function($image->source)) {
233
    if (imageistruecolor($image->resource)) {
234
      return TRUE;
235
    }
236
    else {
237
      // Convert indexed images to truecolor, copying the image to a new
238
      // truecolor resource, so that filters work correctly and don't result
239
      // in unnecessary dither.
240
      $resource = image_gd_create_tmp($image, $image->info['width'], $image->info['height']);
241
      if ($resource) {
242
        imagecopy($resource, $image->resource, 0, 0, 0, 0, imagesx($resource), imagesy($resource));
243
        imagedestroy($image->resource);
244
        $image->resource = $resource;
245
      }
246
    }
247
    return (bool) $image->resource;
248
  }
249
  return FALSE;
233 250
}
234 251

  
235 252
/**
......
297 314
  $res = imagecreatetruecolor($width, $height);
298 315

  
299 316
  if ($image->info['extension'] == 'gif') {
300
    // Grab transparent color index from image resource.
317
    // Find out if a transparent color is set, will return -1 if no
318
    // transparent color has been defined in the image.
301 319
    $transparent = imagecolortransparent($image->resource);
302 320

  
303 321
    if ($transparent >= 0) {
304
      // The original must have a transparent color, allocate to the new image.
305
      $transparent_color = imagecolorsforindex($image->resource, $transparent);
306
      $transparent = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
307

  
308
      // Flood with our new transparent color.
309
      imagefill($res, 0, 0, $transparent);
310
      imagecolortransparent($res, $transparent);
322
      // Find out the number of colors in the image palette. It will be 0 for
323
      // truecolor images.
324
      $palette_size = imagecolorstotal($image->resource);
325
      if ($palette_size == 0 || $transparent < $palette_size) {
326
        // Set the transparent color in the new resource, either if it is a
327
        // truecolor image or if the transparent color is part of the palette.
328
        // Since the index of the transparency color is a property of the
329
        // image rather than of the palette, it is possible that an image
330
        // could be created with this index set outside the palette size (see
331
        // http://stackoverflow.com/a/3898007).
332
        $transparent_color = imagecolorsforindex($image->resource, $transparent);
333
        $transparent = imagecolorallocate($res, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']);
334

  
335
        // Flood with our new transparent color.
336
        imagefill($res, 0, 0, $transparent);
337
        imagecolortransparent($res, $transparent);
338
      }
339
      else {
340
        imagefill($res, 0, 0, imagecolorallocate($res, 255, 255, 255));
341
      }
311 342
    }
312 343
  }
313 344
  elseif ($image->info['extension'] == 'png') {

Formats disponibles : Unified diff