Page 4 of 4

Re: ogg vorbis comment (tag)

Posted: Mon Aug 26, 2019 9:01 am
by wilbert
You may be right that it has to do with the drawing of the alpha channel.
I would probably change the encode procedure to something like the code below and pass JPEGQuality -1 to encode for PNG.

Code: Select all

; >> EncodeVorbisPicture procedure <<

UseJPEGImageEncoder()
UsePNGImageEncoder()

Procedure.s EncodeVorbisPicture(Image, PictureType = 3, JPEGQuality = 7)
  
  Protected *Image, MIMEType.s, Offset, ImageDataSize, BufferSize
  
  If JPEGQuality >= 0
    ; JPEG
    *Image = EncodeImage(Image, #PB_ImagePlugin_JPEG, JPEGQuality)
    MIMEType = "image/jpeg"
    Offset = 42
  Else
    ; PNG
    *Image = EncodeImage(Image, #PB_ImagePlugin_PNG, 0, 32)
    MIMEType = "image/png"
    Offset = 41
  EndIf
  
  ImageDataSize = MemorySize(*Image)
  BufferSize = ImageDataSize + Offset
  
  ; Allocate Buffer array and copy the encoded image to it
  Protected Dim Buffer.a(BufferSize - 1)
  CopyMemory(*Image, @Buffer(Offset), ImageDataSize)
  FreeMemory(*Image)
  
  ; Set the additional information
  Buffer(3) = PictureType
  Buffer(7) = PokeS(@Buffer(8), MIMEType, -1, #PB_Ascii | #PB_String_NoZero)
  
  Buffer(Offset-4) = ImageDataSize >> 24
  Buffer(Offset-3) = ImageDataSize >> 16
  Buffer(Offset-2) = ImageDataSize >> 8
  Buffer(Offset-1) = ImageDataSize
  
  ; Return Base64 encoded Buffer without CRLF
  ProcedureReturn ReplaceString(Base64Encoder(@Buffer(0), BufferSize), #CRLF$, "")
  
EndProcedure

Re: ogg vorbis comment (tag)

Posted: Mon Aug 26, 2019 10:46 am
by collectordave
Hi wilbert

I attacked it by having two procedures one for jpg and one for png with an extra field in the imagetag for mimetype.

Each png image is encoded with its original depth and then coupled with DrawAlphaImage() it works fine.

Changed it all as I am now starting to get ready to batch tag Artist and title from the filename and to rename files based on the tags.

Maybe could offer support for other image formats such as bmp?

CD

Re: ogg vorbis comment (tag)

Posted: Mon Aug 26, 2019 11:02 am
by wilbert
collectordave wrote:I attacked it by having two procedures one for jpg and one for png
That will also work fine :)
collectordave wrote:Maybe could offer support for other image formats such as bmp?
Bmp isn't allowed. According to the file specification, an image has to be encoded as either jpeg or png.
So you can only load bmp files and recode as png or jpeg before embedding.
When it comes to png and jpeg images, you could also offer to embed the image as it is without recoding it.

Re: ogg vorbis comment (tag)

Posted: Tue Aug 27, 2019 5:23 am
by collectordave
Could load bmp then save as png etc will look into it a bit more.

Just added new li8nk to first page. Barch editing now possible for filename tags and writing filenames from tags.

More open format for the editor as well.

Regards

CD

Re: ogg vorbis comment (tag)

Posted: Tue Aug 27, 2019 5:59 am
by wilbert
Unfortunately the current version doesn't work on macOS.
I think it has to do with the fact that macOS uses a forward slash for directories while Windows uses a backslash.

Re: ogg vorbis comment (tag)

Posted: Tue Aug 27, 2019 7:19 am
by infratec
Wondows also accept / as delimiter for directories :wink:

Re: ogg vorbis comment (tag)

Posted: Tue Aug 27, 2019 9:43 am
by collectordave
Trying on the mac and it works if everything is on the local drive except images.

Just tried openfilerequester on external drive and it fails on the mac posted a maybe bug.

CD

PS There is one bit in the select folder procedure where i use the \ changed to #PS$ and it loads.

Re: ogg vorbis comment (tag)

Posted: Tue Aug 27, 2019 10:11 am
by wilbert
collectordave wrote:Trying on the mac and it works if everything is on the local drive except images.

Just tried openfilerequester on external drive and it fails on the mac posted a maybe bug.

CD

PS There is one bit in the select folder procedure where i use the \ changed to #PS$ and it loads.
If I change the backslash, it does show the ogg files in a folder.
At first I assumed it would immediately show something if I would click on a filename but apparently I have to use the right-click button ?
If I do so, I can open a file and "Current song" shows the filename but the comment tags don't show anything.

Re: ogg vorbis comment (tag)

Posted: Tue Aug 27, 2019 10:25 am
by collectordave
Hi

After selecting a folder and the ogg files are shown in the list then right click gives the popup menu then select Load file and on my machine it shows the comments.


The popup is used to allow you to select multiple files to tag or rename.

CD

Re: ogg vorbis comment (tag)

Posted: Tue Aug 27, 2019 1:12 pm
by wilbert
collectordave wrote:After selecting a folder and the ogg files are shown in the list then right click gives the popup menu then select Load file and on my machine it shows the comments.
It does show the tags now. Maybe I did something wrong.
There is however still a problem with showing embedded images.

ResizeImage doesn't return an image but resizes the original image.
Also when you draw an image, you need the ImageID which is not the same as the image number.
If you use DrawVectorImage, you don't need to resize the image and as far as I know, it will still work with transparent images.

Code: Select all

      If StartVectorDrawing(CanvasVectorOutput(cnvArtWork))
        MovePathCursor(0, 0)
        DrawVectorImage(ImageID(EditTags()\ImageID), 255, adjustedwidth, adjustedheight)
        StopVectorDrawing()     
      EndIf

Re: ogg vorbis comment (tag)

Posted: Wed Aug 28, 2019 3:58 am
by collectordave
Link on first page updated with (working code) tested on mac and win7 64bit pb 5.71

CD

Re: ogg vorbis comment (tag)

Posted: Wed Aug 28, 2019 6:35 am
by wilbert
collectordave wrote:Link on first page updated with (working code) tested on mac and win7 64bit pb 5.71
It works better now :)

When I open an ogg file with a front cover image in it, select one of the image types (Back Cover or Artist) that doesn't have an image and select "Front Cover" again, I get a crash.

Re: ogg vorbis comment (tag)

Posted: Wed Aug 28, 2019 6:49 am
by collectordave
Works ok on windows will dig out mac and try

Cd

Re: ogg vorbis comment (tag)

Posted: Wed Aug 28, 2019 6:58 am
by collectordave
Missed one

Lines 837 etc in new win main need to be changed

Code: Select all

  
                StartVectorDrawing(CanvasVectorOutput(cnvArtWork))
                    MovePathCursor(0,0)
                    DrawVectorImage(ImageID(EditTags()\ImageID),255,adjustedwidth,adjustedheight)
                  StopVectorDrawing()
Did the rest forgot this one.

Please try and tell me if this vures problem.

CD

Re: ogg vorbis comment (tag)

Posted: Wed Aug 28, 2019 9:27 am
by wilbert
collectordave wrote:Lines 837 etc in new win main need to be changed
That fixes the problem. :)