DEV Community

loading...

March Media Madness Takeaways [Yet Another Cloudinary Blog post] - Part II

shazomii profile image Shazomii ・12 min read

#MarchMediaMadness

This is the second part of a 3 part series I'm writing about the Guess the Transformation challenge being hosted by Prosper Otemuyiwa (@unicodeveloper) and Cloudinary.

Here's a link to the first part of the series to get you up to speed.

As I noted in the first post, most of these challenges can be solved using various approaches. The purpose of this post is to try to show how the solution to each day's challenge is derived.

I have also included a link to the Cloudinary Cookbook recipe/documentation related to each day's challenge for you to check out more media magic!

This second part covers the next 10 days (11th March - 20th March, 2020).

Let's go!


Day 11 (March 11th)

Recipe: Eyes Overlays

https://res.cloudinary.com/cdemo/image/upload/v1583944329/_mmm/finepeople.jpg

First Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1583944329/_mmm/finepeople.jpg

https://res.cloudinary.com/cdemo/image/upload/v1583943678/_mmm/glasses.png

Second Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1583943678/_mmm/glasses.png

https://res.cloudinary.com/cdemo/image/upload/fl_region_relative,g_adv_eyes,l__mmm:glasses,w_1.5/_mmm/finepeople.jpg

Expected result

For this challenge, we'll make use of Cloudinary's Advanced Facial Attribute Detection feature to smartly overlay glasses on top of every detected eye pair in the first baseline image.

To do this, the overlay parameter, l, is set to the public ID of the glasses image. We when activate Cloudinary's Advanced Facial Attribute Detection feature by setting the gravity parameter, g, to adv_eyes.

Lastly, we'll set the region_relative flag with a 1.5 width. This effectively scales each glasses overlay to 150% of the detected eye pairs.

https://res.cloudinary.com/cdemo/image/upload/fl_region_relative,g_adv_eyes,l__mmm:glasses,w_1.5/_mmm/finepeople.jpg


Day 12 (March 12th)

Recipe: Pixelate Face and Duotone Filter

https://res.cloudinary.com/cdemo/image/upload/_mmm/puppyface.jpg

Baseline Image: https://res.cloudinary.com/cdemo/image/upload/_mmm/puppyface.jpg

https://res.cloudinary.com/cdemo/image/upload/e_pixelate_faces/e_grayscale/e_tint:50:red/_mmm/puppyface.jpg

Expected result

This challenge is a combination of three effects: pixelate, grayscale and tint.

To pixelate the face, we'll set the effect parameter, e, to pixelate_faces. This will detect every face in the image and add pixel squares over each one. The size of the squares can also be set using custom values.

We then create a duotone filter using the grayscale and tint effects. We'll use a red tint and set its strength to 50.

https://res.cloudinary.com/cdemo/image/upload/e_pixelate_faces/e_grayscale/e_tint:50:red/_mmm/puppyface.jpg


Day 13 (March 13th)

Recipe: Style Transfer

https://res.cloudinary.com/cdemo/image/upload/_mmm/community.jpg

First Baseline Image: https://res.cloudinary.com/cdemo/image/upload/_mmm/community.jpg

https://res.cloudinary.com/cdemo/image/upload/v1584104910/_mmm/moulin.jpg

Second Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1584104910/_mmm/moulin.jpg

https://res.cloudinary.com/cdemo/image/upload/w_1000,h_800,c_fill/e_style_transfer,l__mmm:moulin/_mmm/community.jpg

Expected result

For this challenge, we'll make use of Cloudinary's cool Neural Artworks feature to transfer the styles from the second baseline image onto the first baseline image. To do this, we'll set the effect parameter to style_transfer.

We'll also resize the image using the width and height parameters to get the same dimensions as the expected result.

https://res.cloudinary.com/cdemo/image/upload/w_1000,h_800,c_fill/e_style_transfer,l__mmm:moulin/_mmm/community.jpg


Day 14 (March 14th)

Recipe: Outline Effect

https://res.cloudinary.com/cdemo/image/upload/_mmm/bottomleaves.png

Baseline Image: https://res.cloudinary.com/cdemo/image/upload/_mmm/bottomleaves.png

bottomleaves.png

Expected result

To recreate this rainbow-like pattern, we'll make use of the outline effect. This effect, as the name implies, creates an outline around a transparent image.

The outline effect has a default color of black. To create our own colors, we'll set the color parameter, co, to a color of our choice.

We can then create successive outline effect components to achieve the multi-colored outline in this challenge.

https://res.cloudinary.com/cdemo/image/upload/e_outline,co_red/e_outline,co_rgb:FF7F00/e_outline,co_yellow/e_outline,co_rgb:00FF00/e_outline,co_blue/e_outline,co_rgb:4B0082/e_outline,co_rgb:9400D3/e_outline,co_red/e_outline,co_rgb:FF7F00/e_outline,co_yellow/e_outline,co_rgb:00FF00/e_outline,co_blue/e_outline,co_rgb:4B0082/e_outline,co_rgb:9400D3/_mmm/bottomleaves.png


Day 15 (March 15th)

Recipe: Displacement Mapping

https://res.cloudinary.com/cdemo/image/upload/v1584251882/_mmm/mug.jpg

First Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1584251882/_mmm/mug.jpg

https://res.cloudinary.com/cdemo/image/upload/v1584251791/_mmm/radial.jpg

Second Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1584251791/_mmm/radial.jpg

https://res.cloudinary.com/cdemo/image/upload/v1584252577/_mmm/tweet.png

Third Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1584252577/_mmm/tweet.png

https://res.cloudinary.com/cdemo/image/upload/c_scale,w_320/c_pad,h_2.0,w_1.0/e_displace,l__mmm:radial,y_-9/e_trim/c_scale,u__mmm:mug,w_690,x_-1,a_vflip.180/_mmm/tweet.png

Expected result

One of Cloudinary's more robust transformations is the displace effect, which applies another image as a displacement map to manipulate your base image in a variety of ways. The displacement mapping algorithm evaluates every pixel in the image map and then displaces the pixels in the base image based on the intensity of the corresponding image map pixels.

For this challenge, we've been provided with a displacement template (second baseline image) which we are going to apply on the tweet image.

This particular challenge is a good example of one that can be solved in various ways, so it'll be interesting to see how you approach it.

Besides the displace effect, I'll also like to touch upon the trim effect and angle parameter, a.

The trim effect analyses the image and smartly trims off unused white-spaces.

We apply the angle parameter on the mug to mirror the original mug. To achieve this, we'll flip it vertically at an angle of 180 by setting the angle parameter to vflip.180.

https://res.cloudinary.com/cdemo/image/upload/c_scale,w_320/c_pad,h_2.0,w_1.0/e_displace,l_mmm:radial,y-9/e_trim/c_scale,u_mmm:mug,w_690,x-1,a_vflip.180/_mmm/tweet.png


Day 16 (March 16th)

Recipe: Color Mapping

https://res.cloudinary.com/cdemo/image/upload/_mmm/handbag.png

Baseline Image: https://res.cloudinary.com/cdemo/image/upload/_mmm/handbag.png

https://res.cloudinary.com/cdemo/image/upload/e_replace_color:cyan:80:2b38aa/e_outline:15:200,co_orange/_mmm/handbag.png

Expected result

To complete this challenge, we'll make use of two effects: outline, which we first saw in day 14 challenge, and replace_color, which effectively replaces shades of predominant or custom colors in an image with shades of a different.

Here's the syntax for replace_color effect: e_replace_color:[TO_COLOR]:[THRESHOLD]:[FROM_COLOR]. In this case, we want to replace the color blue with cyan.

The syntax for outline effect is: e_outline:[MODE]:[WIDTH]:[BLUR]. In day 14 challenge, we made use of the default values for the 3 parameters. For this challenge, we'll stick to the default value for mode (inner and outer), but we'll set custom values for both width and blur.

https://res.cloudinary.com/cdemo/image/upload/e_replace_color:cyan:80:2b38aa/e_outline:15:200,co_orange/_mmm/handbag.png


Day 17 (March 17th)

Recipe: Image Overlay/Underlay

https://t.co/6yI6Hy0DHU?amp=1

First Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1584510574/_mmm/human.png

https://res.cloudinary.com/cdemo/image/upload/v1584510559/_mmm/desert.jpg

Second Baseline Image: https://res.cloudinary.com/cdemo/image/upload/v1584510559/_mmm/desert.jpg

https://res.cloudinary.com/cdemo/image/upload/w_800,f_auto,q_auto/u__mmm:desert,h_1000/_mmm/human.png

Expected result

Personally, I think there's an inside joke in today's challenge that I didn't get. For context, this is the only challenge with a title: "Zoom Change Backgroundβ€”Remote fun". I'm not quite sure what that's about or maybe it doesn't even mean anything, but if you get it, do let me know in the comments. :)

So, on to the challenge.

There are at least two ways we can solve this challenge. We could either overlay the baseball player on the desert or underlay the desert beneath the baseball player. Either way works just fine.

The winner went with the underlay method and also made some adjustments to the dimensions.

https://res.cloudinary.com/cdemo/image/upload/w_800,f_auto,q_auto/u__mmm:desert,h_1000/_mmm/human.png


Imgur

The organizers of this challenge decided to step things up a notch by deviating from image transformation and manipulation to video!

I'm writing this post on the 27th of March. There hasn't been any image challenge since the 17th, so I guess it's safe to say we'll be having video challenges for the rest of the month. C'est bien.

You might want to check out the Cloudinary documentation on Video Transformations before proceeding. Also, check out the doucmentation on Resizing and Cropping Videos, as we'll likely be doing a lot of that and the documentation does a perfect job of outlining what each crop mode does.

Day 18 (March 18th)

Recipe: Concatenate Videos with Images

https://res.cloudinary.com/cdemo/image/upload/_mmm/washyourhands.png

Baseline Image: https://res.cloudinary.com/cdemo/image/upload/_mmm/washyourhands.png

Imgur

Baseline Video: https://res.cloudinary.com/cdemo/video/upload/_mmm/washhands.mp4

https://gblobscdn.gitbook.com/assets%2F-M1J0YPWDmPTjECch_HO%2F-M2iP2bLrQ18auYKMD8H%2F-M2igLVlSGAIswcEMTx8%2FScreen%20Shot%202020-03-18%20at%206.29.06%20PM.png?alt=media&token=afec096f-87cb-4cc6-97c7-e56966009667

Expected result

For this challenge, we want to concatenate the image named washyourhands to the start of the video named washhands for a duration of 5 seconds (both the video and image will also be scaled to a width of 500 pixels and a height of 400 pixels for uniformity).

We'll achieve this by using the following combination of parameters:

  • overlay, l, to specify the name of the image,
  • splice flag, fl_splice, to indicate that the image should be concatenated on to the container video and not added as an overlay,
  • duration parameter, du, to specify the amount of time in seconds to display the image,
  • start_offset set to 0, so_0, to concatenate the image at the beginning of the video instead of at the end.
  • layer_apply flag, fl_layer_apply, to indicate that the above parameters are applied to the image with the overlay parameter and not the base video.

https://res.cloudinary.com/cdemo/video/upload/w_500,h_400/w_500,h_400,l__mmm:washyourhands,fl_splice,du_5/so_0,fl_layer_apply/_mmm/washhands.mp4


Day 19 (March 19th)

Recipe: Blurred Video Background

Imgur

Baseline Video: https://res.cloudinary.com/cdemo/video/upload/_mmm/baseball.mp4

https://gblobscdn.gitbook.com/assets%2F-M1J0YPWDmPTjECch_HO%2F-M2oAYwJ4noOoVq1S26F%2F-M2oAdpYPJg3AySJA2ql%2FScreen%20Shot%202020-03-19%20at%208.04.06%20PM.png?alt=media&token=d659cc8c-ccc2-4535-bfc6-6c108b20dad1

Expected result

Right off the bat (pun intended), the differences between the two videos are quite clear. The aspect ratio of the base video has been switched to a square and a blurred version of the same video has been added to fill out the cropped space.

To achieve this, we resize the base video to square proportions and apply a fill crop mode. We then add a background by setting the background parameter, b, to blurred, with a blur intensity of 400 and a brightness value of 15.

If we leave it this way, the blurred background will remain invisible behind the video with some funny things happening with the video's duration. We don't want that. To stretch it out, we'll adjust it's dimensions to a width of 600 pixels and height of 320 pixels with a pad crop mode.

https://res.cloudinary.com/cdemo/video/upload/w_300,h_300,c_fill/c_pad,h_320,w_600,b_blurred:400:15/_mmm/baseball.mp4


Day 20 (March 20th)

Recipe: Fade In, Fade Out

Imgur

Baseline Video: https://res.cloudinary.com/cdemo/video/upload/_mmm/geng.mp4

https://gblobscdn.gitbook.com/assets%2F-M1J0YPWDmPTjECch_HO%2F-M2swlYexLH1O5A8u5s4%2F-M2t4_x-8xz10BKTKNNe%2FScreen%20Shot%202020-03-20%20at%206.55.33%20PM.png?alt=media&token=18a25ea7-c2cc-41c6-87b6-96d15d0eca37

Expected result

The text overlay effect we last saw in Day 8 makes a comeback in this challenge with an added superpower: the ability to step in and out of a video at specified times. Cool, right?

We achieve this using the start offset, so, and end offset, eo, parameters. We'll set both to the times we want the text overlay to step in and out of the video respectively.

We'll also apply two fade effects, e_fade, to the video: one at the beginning and another at the end. The effect accepts a parameter that determines the duration of the fade effect in milliseconds, with a positive value for fading in at the beginning of the video, and a negative value for fading out at the end of the video.

https://res.cloudinary.com/cdemo/video/upload/l_text:arial_60:Geng Of The Most High,g_north,y_80,so_2,eo_5/e_fade:2500/e_fade:-5000/_mmm/geng.mp4


If you made it this far, trust me, you can make it through anything!

As always, please experiment with other recipes in the cookbook and feel free to share your stunning creations in the comments below!

Watch out for the final part!

Cheers!

Discussion

pic
Editor guide