<commit_before>part of image;

/**
 * Returns a resized copy of the [src] image.
 * If [height] is -1, then it will be determined by the aspect
 * ratio of [src] and [width].
 */
Image copyResize(Image src, int width, [int height = -1,
                 int interpolation = LINEAR]) {
  if (height < 0) {
    height = (width * (src.height / src.width)).toInt();
  }

  if (width <= 0 || height <= 0) {
    throw new ImageException('Invalid size');
  }

  Image newImage = new Image(width, height, src.format);

  double dy = src.height / height;
  double dx = src.width / width;

  // Copy the pixels from this image to the new image.
  for (int y = 0; y < height; ++y) {
    double y2 = (y * dy);
    for (int x = 0; x < width; ++x) {
      double x2 = (x * dx);
      newImage.setPixel(x, y, src.getPixelInterpolate(x2, y2, interpolation));
    }
  }

  return newImage;
}<commit_msg>filter source image during copyResize to improve quality<commit_after>part of image;

/**
 * Returns a resized copy of the [src] image.
 * If [height] is -1, then it will be determined by the aspect
 * ratio of [src] and [width].
 */
Image copyResize(Image src, int width, [int height = -1,
                 int interpolation = LINEAR]) {
  if (height < 0) {
    height = (width * (src.height / src.width)).toInt();
  }

  if (width <= 0 || height <= 0) {
    throw new ImageException('Invalid size');
  }

  if (interpolation == LINEAR) {
    src = new Image.from(src);
    src = gaussianBlur(src, 2);
  } else if (interpolation == CUBIC) {
    src = new Image.from(src);
    src = gaussianBlur(src, 3);
  }

  Image dst = new Image(width, height, src.format);

  double dy = src.height / height;
  double dx = src.width / width;

  // Copy the pixels from this image to the new image.
  for (int y = 0; y < height; ++y) {
    double y2 = (y * dy);
    for (int x = 0; x < width; ++x) {
      double x2 = (x * dx);
      dst.setPixel(x, y, src.getPixelInterpolate(x2, y2, interpolation));
    }
  }

  return dst;
}
{'fraction_non_alphanumeric': 0.14492753623188406, 'fraction_numerical': 0.01199400299850075, 'mean_word_length': 2.6137184115523464, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4021437', 'n_tokens_mistral': 702, 'n_tokens_neox': 672, 'n_words': 242}