code: func (f *Fpdf) parsejpg(r io.Reader) (info *ImageInfoType) {
  	info = f.newImageInfo()
  	var (
  		data bytes.Buffer
  		err  error
  	)
  	_, err = data.ReadFrom(r)
  	if err != nil {
  		f.err = err
  		return
  	}
  	info.data = data.Bytes()
  
  	config, err := jpeg.DecodeConfig(bytes.NewReader(info.data))
  	if err != nil {
  		f.err = err
  		return
  	}
  	info.w = float64(config.Width)
  	info.h = float64(config.Height)
  	info.f = "DCTDecode"
  	info.bpc = 8
  	switch config.ColorModel {
  	case color.GrayModel:
  		info.cs = "DeviceGray"
  	case color.YCbCrModel:
  		info.cs = "DeviceRGB"
  	case color.CMYKModel:
  		info.cs = "DeviceCMYK"
  	default:
  		f.err = fmt.Errorf("image JPEG buffer has unsupported color space (%v)", config.ColorModel)
  		return
  	}
  	return
  }
docs: // parsejpg extracts info from io.Reader with JPEG data
  // Thank you, Bruno Michel, for providing this code.