How do these two lines get replaced?  IIRC, there aren't reliable EXIF tags that give the actual image size in pixels the way these values do.  So if you're going to replace jpeg_metadata_parser (which I don't think is a good idea) you'll need to get the image width and height from this  non-EXIF segment.