Why doesn't setImageInterlaceScheme() make a jpeg progressive? - pecl

I'm using php Gmagick to modify images. The following code works as expected except that the images are not progressive. Why? According to the GraphicsMagick docs it should. For reference, the input image is 666 x 1000.
$img = new Gmagick();
$img->setSize(900, 900)
->readImageBlob($image->getBytes())
->setImageInterlaceScheme(Gmagick::INTERLACE_PLANE)
->setImageResolution(96, 96)
->setImageFormat('jpeg')
->setCompressionQuality(70)
->resizeImage(900, 1351, Gmagick::FILTER_UNDEFINED, 1);
Note that
$img->getImageInterlaceScheme() === Gmagick::INTERLACE_PLANE
does return true after setting it.
Edit
I've tried both the INTERLACE_LINE and INTERLACE_PLANE constants. With neither seeming to have an effect on the output.

The original author created a bug on php.net (https://bugs.php.net/bug.php?id=66444), where the correct answer was eventually posted. You need to use the undocumented method:
->setInterlaceScheme(Gmagick::INTERLACE_LINE)
Instead of:
->setImageInterlaceScheme(Gmagick::INTERLACE_LINE)
This worked for me! For reference I am using PHP 5.4.20 with gmagick 1.1.7RC2 on top of GraphicsMagick 1.3.18.

The documentation you point to states:
Use Line to create an interlaced PNG or GIF or progressive JPEG image.
So, I think you should be setting the interlace to line.
->setImageInterlaceScheme(Gmagick::INTERLACE_LINE)
Note: I'm not sure if INTERLACE_LINE is an actual value. I assumed it was based on your code. Basically, try the line option.

Have you tried calling setImageInterlaceScheme before anything else? i cannot find the code, but maybe when you read the bits it already compose the image and then the interlacings takes no place.
$img
->setImageInterlaceScheme(Gmagick::INTERLACE_PLANE)
->readImageBlob($image->getBytes())
->setSize(900, 900)
->setImageResolution(96, 96)
->setImageFormat('jpeg')
->setCompressionQuality(70)
->resizeImage(900, 1351, Gmagick::FILTER_UNDEFINED, 1);
For sure the interlaceScheme has to be INTERLACE_PLANE, as you can read in the docs you already know http://www.graphicsmagick.org/GraphicsMagick.html#details-interlace

I've finally found the answer to this (using PHP IMagick) after struggling for weeks.
It turns out you have to set the image format to 'pjpeg' instead of just jpeg.
I have no idea why by by doing so my Images are correctly detect as progressive and render progressively in the browser.
I assume this will be the same for 'GMagick'
$im->setImageFormat('pjpeg')

Related

How to properly use QSkyBoxEntity?

I looked everywhere, but there are not any guides or explanations of how to use QSkyBoxEntity.
I created Entity and filled it with transform (set translation and 3d scale). Also changed name and extension.
When I'm trying to run program it says
"Qt3D.Renderer.OpenGL.Backend: Unable to find suitable Texture Unit for "skyboxTexture""
I checked several times and tried different png files but no luck.
My image (I know it's fake transparency, but it shouldn't change anything, right?)
And here's part of a code:
Qt3DCore::QEntity *resultEntity = new Qt3DCore::QEntity;
Qt3DExtras::QSkyboxEntity *skyboxEntity = new Qt3DExtras::QSkyboxEntity(resultEntity);
skyboxEntity->setBaseName("skybox"); //I tried using path as well
skyboxEntity->setExtension("png");
Qt3DCore::QTransform *skyTransform = new Qt3DCore::QTransform(skyboxEntity);
skyTransform->setTranslation(QVector3D(0.0f,0.0f,0.0f));
skyTransform->setScale3D(QVector3D(0.1f,0.1f,0.1f));
skyboxEntity->addComponent(skyTransform);
Looks like it's not finding the skybox texture. Did you use an absolute path when you say "I tried using path as well"? The path you set is relative to the build path, i.e. it's not where your C++ file lies.
Alternatively, you could use a resources file and then load then image using
"qrc:/[prefix]/[filename without extension]"
You can also check out the Qt3D manual SkyBox test here:
https://github.com/qt/qt3d/tree/dev/tests/manual/skybox
It's important to properly name files in order for skybox to work and use resource file for storing.
I recommend .tga, but other formats should work as well.
You can read about it here:
https://doc.qt.io/qt-6/qml-qt3d-extras-skyboxentity.html
And here's example how it should look

videojs-thumbnails plugin shows thumbnails at incorrect time

I'm trying to use "videojs-thumbnails" plugin from https://github.com/brightcove/videojs-thumbnails and noticed that thumbnail's time, specified in the plugin configuration is not matching the timestamp in the seek bar. Coming across different comments regarding this issue I found suggestion at https://github.com/brightcove/videojs-thumbnails/issues/43 to replace line
mouseTime = Math.floor((left - progressControl.el().offsetLeft) / progressControl.width() * duration);
to
mouseTime = Math.floor((left) / progressControl.width() * duration);
By removing
- progressControl.el().offsetLeft
However, that produces still not exact time match.
Finally I came with redefined value for the
var left
Getting it from the current value of
.vjs-mouse-display
So, my final codes are:
left=parseInt((document.querySelector('.vjs-mouse-display').style.left),10);
mouseTime = Math.floor((left) / progressControl.width() * duration);
Now everything works correctly.
Greatly appreciate for comments/suggestions.
This is NOT an answer to your specific question / issue, but rather, an alternative implentation approach.
I, too, wanted thumbnails for my video(s), so I proto-typed a page
that used videoJS's plugin. I don't recall all the details of the
issues that I ran into trying to use that plugin, but I finally decided
to abandon the plugin, and design an alternative, which has its own
separate 'slider' just above the viewer. [ One 'drags' my slider,
(rather than hover along it, as you do on YouTube's videos), so that it
can work straight-forwardly on touch-screens...i.e. on Android, etc. ]
And, rather than try to extract images from the video in real-time,
(See: How to generate video preview thumbnails for use in VideoJS? ), I chose to prepare the images, ahead of time, using 'ffmpeg' and the cmd-line interface to 'ImageMagick'.
Details of that part are here:
http://weasel.firmfriends.us/GeeksHomePages/subj-video-and-audio.html#implementing-video-thumbnails
My 'proof-of-concept' webpage based on that approach is here:
https://weasel.firmfriends.us/Private3-BB/
I hope this is helpful.

TextControl Images/Watermarks

In version 18 of TextControl (http://www.textcontrol.com) there is supposed to be the ability to add background images/watermarks to the document, however I find that the behavior of the various overloads, etc is not working correctly and that the documentation is rather scarce on examples. Does any one have a working example of adding watermarks to a Word document through the ServerTextControl object?
This functionality didn't exist in previous versions, so I recognize it's still rather new, I just find it weird that doing something like
tx.Images.Add(draftImage, pageNumber, location, ImageInsertionMode.BelowTheText);
doesn't actually add the images to the document, but if I use another overload beforehand, it adds both?
I just need a loop along the lines of
foreach (TXTextControl.Page page in pages){
page.Select();
var location = tx.InputPosition.Location;
var pageNumber = page.Number;
tx.Images.Add(draftImage, pageNumber, location, ImageInsertionMode.BelowTheText);
}
where location is supposed to be the beginning of the page.
Any help would be appreciated, this should be simple!
Thank you
Finally got a response to this on their forum, it's not a complete solution, but it works for the most part. Figured I would follow up here, so that anyone who ends up on this page would get the help I wanted.
http://forums.textcontrol.com/showthread.php?325522-Watermarking-Background-Image-on-Saved-Documents-in-X8&p=41815#post41815

Every velocity tool escape function working except url()?

I can get $esc.html to work, but not $esc.url, it just comes up literal even though I follow example at: http://velocity.apache.org/tools/devel/generic/EscapeTool.html
Interestingly enough, on that page the url() section's head is "$attrib.name" instead of url().
Any ideas?
Thanks.
Worked for me in Tools 2.0. Maybe you have old version?
$esc.url("bread & butter") = bread+%26+butter

What does visibleContentsAsDataURL exactly do?

I am currently trying to build my first Safari extension. The SafariBrowserTab Class has a Method called "visibleContentsAsDataURL".
I don't exactly understand what it does and can't get it to work.
The docs just say: "Returns a data URL for an image of the visible contents of the tab."
What does it mean? That I get the URL of a screenshot of the tabs' content back? Can someone explain me?
Thanks!
I think it returns what is effectively a screenshot of the tab. The format is explained here
http://en.wikipedia.org/wiki/Data_URI_scheme
According to Apple's Safari reference documentation the return value is "a base-64 encoded PNG."
A data URL is a specal type of url basically consisting of a mimetype and data, in the case of png you'll get something along the lines of:
data:image/png;base64;lotsofstuff
You can then do whatever you want with it (it's just a string), or if you want to display the content:
img = new Image();
img.src = someTab.visibleContentsAsDataURL();
someElement.appendChild(img);
or
someCanvasContext.drawImage(img);
etc