I've recently had to get a solution to move a corrupted Joomla site, but K2 items was a big problem because images where HMTL inserted, I mean not using HASH K2 method.
Hundred of images have to be inserted into its posts, so I build up a bash to get it done perfectly !!
'Convert' command comes from ImageMagick package
Create script into your K2 media image directory
usually : /var/www/html/media/k2/items/cache/
All my images are JPG so ..
Run bash using ---> for x in *.jpg ; do . k2.img.sh $x ; done
script get every file name without '.jpg', get its HASH , cut final trash , then CONVERT generate several image version acording K2 size rules of each one, and so on for every JPG file
Hope be useful
FER
#!/bin/bash
echo 'Trabajando : ' $1
a=Image${1/.jpg/}
hash="$(echo -n "$a" | md5sum )"
echo 'Este es hash : '$hash
xxx=${hash/ -/}
echo 'Item / Hash : ' $1 $xxx.jpg
convert "$1" -resize 100 "$xxx"_XS.jpg
convert "$1" -resize 200 "$xxx"_S.jpg
convert "$1" -resize 400 "$xxx"_M.jpg
convert "$1" -resize 600 "$xxx"_L.jpg
convert "$1" -resize 900 "$xxx"_XL.jpg
convert "$1" -resize 300 "$xxx"_Generic.jpg