<commit_before>package blend

import (
  "image"
)

func BlendImage(source, dest image.Image, mode int) (image.Image, error) {

  if source.ColorModel() != dest.ColorModel() {
    return nil, BlendError{"Source and destination images have different color models."}
  }

  swidth, sheight := getWidthAndHeight(source)
  dwidth, dheight := getWidthAndHeight(dest)

  if swidth != dwidth {
    return nil, BlendError{"Source and destination images have different widths."}
  }
  if sheight != dheight {
    return nil, BlendError{"Source and destination images have different heights."}
  }

  img := image.NewRGBA64(image.Rect(0, 0, dwidth, dheight))

  for x := 0; x < dwidth; x++ {
    for y := 0; y < dheight; y++ {
      img.Set(x, y, BlendColor(source.At(x, y), dest.At(x, y), mode))
    }
  }

  return img, nil
}

func getWidthAndHeight(img image.Image) (width, height int) {
  width = img.Bounds().Max.X - img.Bounds().Min.X
  width = img.Bounds().Max.Y - img.Bounds().Min.Y
  return
}
<commit_msg>Fixed bug on getImageWidthAndHeight<commit_after>package blend

import (
  "image"
)

func BlendImage(source, dest image.Image, mode int) (image.Image, error) {

  if source.ColorModel() != dest.ColorModel() {
    return nil, BlendError{"Source and destination images have different color models."}
  }

  swidth, sheight := getWidthAndHeight(source)
  dwidth, dheight := getWidthAndHeight(dest)

  if swidth != dwidth {
    return nil, BlendError{"Source and destination images have different widths."}
  }
  if sheight != dheight {
    return nil, BlendError{"Source and destination images have different heights."}
  }

  img := image.NewRGBA64(image.Rect(0, 0, dwidth, dheight))

  for x := 0; x < dwidth; x++ {
    for y := 0; y < dheight; y++ {
      img.Set(x, y, BlendColor(source.At(x, y), dest.At(x, y), mode))
    }
  }

  return img, nil
}

func getWidthAndHeight(img image.Image) (width, height int) {
  width = img.Bounds().Max.X - img.Bounds().Min.X
  height = img.Bounds().Max.Y - img.Bounds().Min.Y
  return
}

{'fraction_non_alphanumeric': 0.14081733136386015, 'fraction_numerical': 0.005908419497784343, 'mean_word_length': 3.5972850678733033, 'pattern_counts': {'":': 0, '<': 7, '<?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': '992363', 'n_tokens_mistral': 708, 'n_tokens_neox': 683, 'n_words': 193}