On Mar 7, 2014, at 5:00 AM, [email protected] wrote:

> All I'm looking for is a way to get the poster frame of a video (if it 
> exists) without QuickTime. Likewise, I just need a way to check if a 
> FolderItem is a picture, again without using QuickTime.
> 
> I'm probably misunderstanding something...

In a project that I did a while back I needed to get the dimensions of graphics 
files. As you probably know this information is stored differently for each 
graphic type. The one good thing though is that it is common that the first 
four bytes of a graphic file can be used to determine what kind of graphic file 
it is and once knowing that the proper code can be used to obtain the 
dimensions of that graphic. 

The following code  is used to determine which graphic format the file is. Once 
determined it calls the analyseXXX method that will get the dimensions of that 
graphic. It works for BMP, GIF, JPG, PNG, TIF and PICT files. IF you need other 
graphic types I imagine you could find the specs for that file type and add the 
proper check of the first four bytes to the following code.

The graphic file is opened as a binary stream file in order to read the first 
four bytes into a UInt32 property.
fileIdent is a Uint32 property.

You should be able to use this to come up with code for your project to 
identify graphics file types.

  bs = BinaryStream.Open(f, False)
  if bs = nil then
    s = "Unable to open the selected file """ + f.name + " in the 
analyseGraphic method"
    showAlertDialog kPgmErr, s, "Okay", "", "", "a", "", 0
    Return
  end if
  fileIdent = bs.readUint32  // read first four bytes from the file
  firstFour = Right("0000000" + hex(fileIdent), 8)
  if left(firstFour, 4) = "424D" then  // first two bytes 424D (BM) a BMP file?
    analyseBMP
  else
    select case firstFour
    case  "47494638"  // test if first four bytes are &h47494638 (GIF8) a GIF 
file
      analyseGIF
    case  "FFD8FFE0"  // test if first four bytes are &hFFD8FFE0 for a JPG file
      analyseJPG
    case "FFD8FFE1"
      analyseJPG
    case "89504E47"  // test if first four bytes are &h89504E47 for a PNG file
      analysePNG
    case "4D4D002A"  // is this one of the TIF identifiers?
      analyseTIF
    case "49492A00"  // is this the other TIF identifier?
      bs.LittleEndian = true  // this TIF format has low byte first
      analyseTIF
    case "00000000"  // does this look like a PICT file can't find any written 
spec for PICT
      analysePCT
    else
      imageKind = "?"  // not a known image file
    end Select
  end if
  bs.Close
  




=== An Apple addict in Tennessee ===

_______________________________________________
Mbsplugins_monkeybreadsoftware.info mailing list
[email protected]
https://ml01.ispgateway.de/mailman/listinfo/mbsplugins_monkeybreadsoftware.info

Reply via email to