W09Y18 – Merge images, SAPUI5 Image component, Raspberry Pi SSH over USB

Merge images

If you need to merge mutiples images in one, I’ll warmly recommend you to use this JavaScript library: https://github.com/lukechilds/merge-images.

Yes, I know what you are going to tell me: it’s possible to do it without any library but it’s more complicated, and not easy to maintain. For example, to do the same in pure JavaScript, you have to play with canvas… below a little example:

var c=document.getElementById("myCanvas");
var ctx=c.getContext("2d");
var imageObj1 = new Image();
var imageObj2 = new Image();
imageObj1.src = "1.png"
imageObj1.onload = function() {
   ctx.drawImage(imageObj1, 0, 0, 328, 526);
   imageObj2.src = "2.png";
   imageObj2.onload = function() {
      ctx.drawImage(imageObj2, 15, 85, 300, 300);
      var img = c.toDataURL("image/png");
      document.write('<img src="' + img + '" width="328" height="526"/>');
   }
};

It’s not as sexy as…

mergeImages(['/body.png', '/eyes.png', '/mouth.png']).then(b64 => document.querySelector('img').src = b64);

Agree? And you have some interesting features:

– positioning (x, y) – opacity – size (width, height)

And it’s under MIT licence.

SAPUI5, fix error 404 on sap.m.Image component

I developed some apps using the SAP UI5 frontend framework and on each app, I have the same errors in the console on each page I use the SAPUI5 Image component (sap.m.Image).

It’s not a blocking point or something really embarrassing but… if someone opens the console, it’s weird.

It’s due to retina support (good intention…) but if you haven’t your images with different densities, it will generate errors (see this article). The solution to avoid this error is to set the densityAware to false.

setDensityAware function.

By default it’s true, but I think that’s bad and should be set to false…

Raspberry Pi Zero & SSH over USB

I realized something very bad: the Raspberry Pi Zero is using a mini HDMI port (see below the HDMI vs mini HDMI)

I was very surprised and little bit blocked because it’s not a adaptor I have in my pocket. Then, I ordered one on AliExpress for less than 2$ (Mini HDMI adaptor).

If you are in the same situation then me, I have a good news, you will not be struggled because you can use your USB to ssh in few easy steps!

Step 1:

On the root of your SD card you have to add the following property at the end of the config.txt file:

dtoverlay=dwc2

Step 2:

On the root of your SD card you have to add the following property just after the rootwait parameter in the cmdline.txt file:

modules-load=dwc2,g_ether

Step 3:

Last step, you have to create a new file named “ssh” without any extension on the root of your SD card. Now connect the Raspberry Pi to your laptop and let it boot. Wait 30 seconds for the RPi to finish the boot, open your terminal and launch the command:

ssh pi@raspberrypi.local

Tadaaaaa

Leave a Reply

Your email address will not be published.