Snippets Collections
from faker import Faker
from SmileyDB3 import SmileyDB3
from random import randint

import webbrowser

f = Faker()
db = SmileyDB3('mydb.db')

users = db.table('users')

for i in range(20):
    users.Insert(data={
        'name': f.name(),
        'email': f.email(),
        'age': randint(20, 40)
    })

users.convert().to_html('out.html')

webbrowser.open('out.html')
import sqlite3

db = sqlite3.connect('mydb.db')
cur = db.cursor()

# create users table
cur.execute('CREATE TABLE IF NOT EXISTS users (name str, image blob)')

# insert new user in users table
cur.execute(
    'INSERT INTO users (name, image) VALUES (?, ?)', 
    ('USER-123', open('smile.png', 'rb').read())
)

db.commit()
from PIL import Image, ImageDraw, ImageOps

def convert_image_to_circle(image_path):
    my_image = Image.open(image_path)
    # create mask 
    mask = Image.new('L', my_image.size)
    draw = ImageDraw.Draw(mask)
    # draw white circle
    draw.ellipse((0, 0) + mask.size, fill = 255)

    # create output image
    output = ImageOps.fit(my_image, mask.size, centering=(0.5, 0.5))
    output.putalpha(mask)
    output.save('out.png')



convert_image_to_circle('test.png')
https://source.unsplash.com/user/c_v_r
import sys

print(sys.argv[0])  # Outputs: script.py
print(sys.argv[1])  # Outputs: arg1
print(sys.argv[2])  # Outputs: arg
     $(function() {
            $("input:file").change(function (){
                let fileName = $(this);
                let cloneFile = fileName.clone();
                $('.manual_payment_attachment_div').hide().html(cloneFile);
                fileName.attr('name', '');
            });
        });
<!doctype html>
<style>
.MyClass123{
    content:url("http://imgur.com/SZ8Cm.jpg");
}
</style>
The image'll appear if your browser supports <code>content:url</code>:

<br><img class="MyClass123"/>
extension UIImageView {
  func setImageColor(color: UIColor) {
    let templateImage = self.image?.withRenderingMode(.alwaysTemplate)
    self.image = templateImage
    self.tintColor = color
  }
}
    func setEditButtonPosition() {
               let x1 = profileImageView.frame.maxX - profileImageView.layer.frame.height/4.5
        let y1 = profileImageView.frame.maxY - profileImageView.layer.frame.height/4.5
        
               statusImageView.frame.origin = CGPoint(x: x1, y: y1)

    }
   func setProfileImage() {
        profileImageView.frame.size = CGSize(width: profileImageView.frame.height,
                                                  height: profileImageView.frame.height)
        profileImageView.layer.cornerRadius = profileImageView.layer.frame.height/2
        profileImageView.center.x = view.center.x
    }
/* CHANGE IMAGE BUTTON SIZE */
.image-button, .image-button.sqs-dynamic-text {
    font-size: .8em !important;
  }
func getImageUrl(){
    print("get Image Url")
    guard let imageData = postPictureImageView.image?.jpegData(compressionQuality: 0.5) else { return }
    let timeStamp = Int(Date().timeIntervalSince1970)
    let storageRef = Storage.storage().reference().child("Posted Images/\(timeStamp).jpg")
    storageRef.putData(imageData, metadata: nil) { (metadata, error) in
        if error != nil {
            print("error")
        } else {
            storageRef.downloadURL { (url, error) in
                if let url =  url?.absoluteString {
                    Url = String(url)
                    }
                }
            }
        }
    }
}
var imagePicker = UIImagePickerController()
var imagePicked = false


    @IBAction func updateProfilePressed(_ sender: Any) {
        let email = emailTextField.text ?? ""
        let phone = phoneNumberTextField.text ?? ""
        
        if nameTextField.text == "" {
            self.showToast(message: "Please enter name")
            return
        } else if !isValidPhone(phone) {
            self.showToast(message: "Please enter a valid phone number")
            return
        }
        
        if imagePicked {
            DB.getImageUrl(profileImageView) { imageUrl in
               let data = [
                    "profileUrl" : imageUrl,
                    "name" : self.nameTextField.text ?? "",
                    "phoneNumber": self.phoneNumberTextField.text ?? "",
                ]
                self.saveData(data)
            }
        } else {
           let data = [
                "name" : self.nameTextField.text ?? "",
                "phoneNumber": self.phoneNumberTextField.text ?? "",
            ]
            self.saveData(data)
        }
    }
    
    func saveData(_ data : [String:Any]) {
        
        let userId = Auth.auth().currentUser?.uid ?? ""
        
        DB.updateDocument("ServiceProviders", userId, data, merge: true) { success in
            if success {
                self.showToast(message: "Profile Updated!")
            }
        }
    }


// MARK: - Image Picker

extension ProfileViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate {
    
    func enableImageViewTapGesture()
        {
            let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(profileImageTapped(tapGesturerecognizer:)))
            profileImageView.isUserInteractionEnabled = true
            profileImageView.addGestureRecognizer(tapGestureRecognizer)
        }
    
    @objc func profileImageTapped(tapGesturerecognizer: UITapGestureRecognizer){
        
        if UIImagePickerController.isSourceTypeAvailable(.savedPhotosAlbum){
            print("Button capture")
            imagePicker.delegate = self
            imagePicker.sourceType = .savedPhotosAlbum
            imagePicker.allowsEditing = true
            
            SVProgressHUD.show()
            present(imagePicker, animated: true) {
                SVProgressHUD.dismiss()
            }
        }
        else {
            print("No")
        }
    }
    
    func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
        
        if let pickedImage = info[UIImagePickerController.InfoKey.originalImage] as? UIImage {
            imagePicked = true
            profileImageView.layer.cornerRadius = profileImageView.bounds.width/2
            profileImageView.image = pickedImage
        }
        self.dismiss(animated: true, completion: nil)
    }
    
    func imagePickerControllerDidCancel(_ picker: UIImagePickerController) {
        
        dismiss(animated: true, completion:nil)
    }
}
# You can use imageMagick to create a gradient image on the fly, but with all the weird possibilities I didn't quite get the hang of it (yet). Anyway, a default 50:50 gradient can be created via "convert -size 100x100 gradient:black-white target.png". To shift the center, you can chain multiple gradients and use the ""-append" flag
❯ convert -size 1000x600 gradient:black-black -size 1000x400 gradient:black-none -append gradient.png

# To use the gradient as a mask on your image, they should be the same size. You can easily resize the image. But keep in mind that imageMagixk respects the proportions and resizes X and Y according to the smaller value
❯ convert gradient.png -resize 1200x800 gradient_resized.png

# Here is how to combine the two, so that you're left with a new image with the mask applied
❯ convert content.jpg gradient_resized.png -alpha on -compose CopyOpacity -composite result.png
star

Sat Apr 20 2024 10:35:22 GMT+0000 (Coordinated Universal Time)

##python #coding #python #image #pil #pillow
star

Tue Apr 09 2024 01:29:12 GMT+0000 (Coordinated Universal Time)

#random #image #url
star

Mon Oct 23 2023 06:23:20 GMT+0000 (Coordinated Universal Time) https://codepen.io/jh3y/pen/abPgrGR

#pop-out #image #scrollers #css #animations
star

Fri Aug 25 2023 03:35:53 GMT+0000 (Coordinated Universal Time)

#args #list #files #embed #image
star

Thu Aug 24 2023 06:17:58 GMT+0000 (Coordinated Universal Time)

#args #list #files #embed #image
star

Tue Jun 20 2023 19:39:39 GMT+0000 (Coordinated Universal Time) https://www.remove.bg/upload

#design #tasktools #designtools #image #image_edit #webassembly
star

Tue May 09 2023 08:40:41 GMT+0000 (Coordinated Universal Time)

#payment #image
star

Sat Jul 16 2022 02:54:23 GMT+0000 (Coordinated Universal Time) http://jsfiddle.net/3BRN7/406/

#addimage #image #addimagecss #cssimagecode
star

Tue May 31 2022 05:47:57 GMT+0000 (Coordinated Universal Time)

#ios #swift #image #imagecolor #imagecolour #changeimagecolour
star

Thu Mar 17 2022 06:21:49 GMT+0000 (Coordinated Universal Time)

#ios #swift #set #setbutton #setimageview #image #button
star

Tue Mar 15 2022 11:50:41 GMT+0000 (Coordinated Universal Time)

#ios #swift #profileimage #image #profile #snippet
star

Thu Feb 03 2022 08:33:59 GMT+0000 (Coordinated Universal Time) https://christyprice.com/blog/change-image-button-size

#button #image #overlay
star

Sat Jan 08 2022 09:45:11 GMT+0000 (Coordinated Universal Time)

#ios #swift #image
star

Wed Jun 09 2021 08:17:27 GMT+0000 (Coordinated Universal Time) terminal help output, try and error and brain stuff

#image #convert #gradient #clipping #mask #transparency #typo3 #imagemagick

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension