Showing posts with label TEXTBOX. Show all posts
Showing posts with label TEXTBOX. Show all posts

Sunday, December 29, 2024

Would you like to watermark and protect your picture?

 You might have been shocked to see one of your pictures or image on someone else's site and felt betrayed. Chances are your name or reference is not even sited, just your image lifted from the internet. Watermarking is your protection against the plagiarism that happens sometimes.

What is watermarking?

Watermarking is the placing of a recognizable form of text or semi-transparent image on your picture so that if someone copies, your marking goes with the picture.

Here is an example of watermarking an image. You can shutterstock all over the image. You can copy from the site but it will have the watermarks.


Watermarking is more, it is branding

Watermarking a picture or an image is not just for protection, it is also your branding tool. Branding is an essential step you should take to be recognized on the internet and by far the most effective. Names like, Nike, Apple, Facebook are most recognizable because of branding. 

It is essential therefore that you take steps to establish your work by copywriting and watermarking.

Tools for watermarking:

There are many tools available for watermarking that are pretty cool. Here are just a few:

Watermarkly: A free, user-friendly tool for adding watermarks to photos

Canva: A free, online tool that lets you add a logo, name, or other visuals to your photos

PicMonkey: A free, online tool for adding watermarks to your images

Fotor: A free, online tool for adding watermarks to your images

Movavi Photo Editor: A free tool for making and editing collages

PhotoMarks: A tool for batch watermarking

Arclab Watermark Studio: A tool for adding multiple watermarks to images

Watermark Software: A tool for fast processing

Format Factory: A tool for watermarking photos and videos

uMark: A tool that uses barcodes and QR codes

This post shows you how to place a watermark on an image of your choosing using Python and an image library.

Python and image libraries have tools to do this. By extending the same concept, you can also watermark videos. I will be placing this text "Hodentek 2025" on the image shown below.


Here is the code in Python that allows you to create watermarks:

=================

import os
from PIL import Image, ImageDraw, ImageFont

try:
# Open the original image
image_path = r"C:\Users\hoden\PycharmProjects\JNumpy\Jay.jpg"
original_image = Image.open(image_path)

# Create a watermark text
watermark_text = "Hodentek 2025"

# Create a new image for the watermark with an alpha layer (RGBA)
watermark_image = Image.new('RGBA', original_image.size, (0, 0, 0, 0))

# Get a drawing context
draw = ImageDraw.Draw(watermark_image)

# Define the font and size (you might need to adjust the font path)
font = ImageFont.truetype('arial.ttf', 72)

# Calculate the bounding box for the watermark text
bbox = draw.textbbox((0, 0), watermark_text, font=font)
text_width, text_height = bbox[2] - bbox[0], bbox[3] - bbox[1]
# position = (original_image.size[0] - text_width - 10, original_image.size[1] \
# - text_height - 10)
# Calculate the position for the watermark (center of the image)
position = ((original_image.size[0] - text_width) / 2, \
(original_image.size[1] - text_height) / 2)
# Draw the watermark text onto the watermark image
draw.text(position, watermark_text, fill=(255, 255, 255, 128), font=font)
# White text with transparency

# Combine the original image with the watermark
watermarked_image = Image.alpha_composite(original_image.convert('RGBA'), \
                                              watermark_image)

# Save and display the result
watermarked_image.show() # To display the image
watermarked_image.save('watermarked_output.png')

print('Watermarked image saved as watermarked_output.png')

except AttributeError as e:
print(f"Error: {e}")
print("Explanation:")
print("Make sure you are using the correct method and attributes.")

except OSError as e:
print(f"Error: {e}")
print("Explanation:")
print("This error likely occurs when the specified font file \
cannot be found or opened.")
print("Please double-check the font path and ensure the font \
file exists.")

except Exception as e:
print(f"An unexpected error occurred: {e}")

Note: Line continuation characters have been used, watch out.

===============

 When you run this code, you will see the image with the watermark at its center  as shown:


Removing watermarks,? yes, Possible:

You may want to know also whether it is possible to remove watermarks. The answer is yes, you can remove watermarks with Python and the watermarked image, but it is more difficult and greater care is needed. Manual editing with Adobe Photoshop or GIMP is also possible. Presently there is an AI tool, Pixnova that removes watermark from photos and it can automatically remove watermark but preserving the original details. AI tools like Fotor and Vmake can help removing watermarks from videos as well.

Dynamic watermarking:

Yes, tools are available for this as well. Oh! you can hide watermarks also.


DynmaicWatermaking.jpg

Friday, April 13, 2018

UWP:How do you control space between controls in XAML?

The easiest way is use the Margin in your control.

The syntax is Margin="left, top, right, bottom"

The next image shows code and design time layout where all textboxes have some space between them. The Button is still attached to the last textbox.


In this image the textboxes are separated from each other by equal spaces and also the 2,3 and 4 th box are left to their previous ones.

Enjoy!

Sunday, April 8, 2018

Can you place a ScrollViewer inside another ScrollViewer in a UWP project?

Yes, as long as the feature is supported.

A ScrollViewer enables content to be displayed in a smaller area than its actual size. When the content of the ScrollViewer is not entirely visible, the ScrollViewer displays scrollbars that the user can use to move the content areas that is visible. The area that includes all of the content of the ScrollViewer is the extent. The visible area of the content is the viewport.

The following contain a ScrollViewer in their templates:

ListView
GridView
TextBox
RichEditBox

In this post you will see a ScrollViewer inside a GridView. The ScrollViewer has two contents, an Image and a TextBox.

The TextBox has its own ScrollViewer with only horizontal scrolling. The default text which is 'Rose' changes to a longer sentence (Event: ViewChanged="SV_ViewChanged") which can be scrolled using your finger or, with the left/right arrow keys when the cursor is anchored in the text box.

The image and the text as a whole can be scrolled both vertically and horizontally.

Here is the project's design view. The default text is 'Rose':


Here is the XAML of the project.

The following is the image when deployed to Local. Notice that the event fired and text box content has changed and the text in the textbox can be scrolled.


This is when deployed to a 4" emulator.

!!I am still trying to figure out why there is a white strip at the top of the image in emulator.


Wednesday, February 14, 2018

How do you access a selected item in XAML's ComboBox Control?

In Part 1, you added after following a few tasks the following to a  Blank UWP project.
  • Getting the ComboBox Control
  • Placing ComboBox on the Design area
  • Adding ComboBoxItems
ComboBox 4

In this post you will write code for an app consisting of a ComboBox, a Button and a TextBox so that when you select an item in the ComboBox and click the button, the selected item appears in the TextBox.

We already have a ComboBox with three items.
We will drag a BUTTON and a TEXTBOX from the Toolbox


ComboBox_8

And drop on the DESIGN pane as shown. The XAML markup is shown in the XAML Pane as shown.


ComboBox_9

We want to Select a ComboBoxItem and then click the BUTTON. This should get displayed in the TEXTBOX.

We add a click EVENT to the button by typing-in Click inside the BUTTON code as shown and choose 'NEW EVENT HANDLER'.


ComboBox_10

It will be named 'Button_Click' as shown.


ComboBox_11

The following will be added to the MainPage.xaml.cs page.

ComboBox_12

We provide names for the ComboBox ('cbx') as well as the TEXT ('txt') box. Now we add the following code to the above newly added code as shown.
-----
 private void Button_Click(object sender, RoutedEventArgs e)
        {
            txt.Text = cbx.SelectionBoxItem.ToString();
        }
-------

Now build, deploy and run the project on Local Machine. When the App is displayed, choose an item (herein, 'BIRD') from the ComboBox and Click the BUTTON, you will see it displayed in the TEXTBOX as shown (the UI is not designed well, it should be improved).


ComboBox_15