Performance – Python Image Combiner Read Write

I'm writing a simple script that combines two images at the pixel level and selects every second pixel from one image and the other pixels from a second image.

from PIL import Image
import struct

print("Photo 1: ", end="")
photo1 = Image.open(input())  # First image, 1920 by 1080
photo1 = photo1.convert("RGB")

print("Photo 2: ", end="")
photo2 = Image.open(input()) # Second image, 1920 x 1080
photo2 = photo2.convert("RGB")

width = photo1.size(0)  # define W and H
height = photo1.size(1)

print("Output file: ", end="")
output = input()
data = str.encode("")
for y in range(0, height):  # counts to 1079
    row = ""
    for x in range(0, width):# counts to 1920
        if ((y + x) % 2) == 0: # makes every other pixel and alternates
                               # on each line, making a checker board pattern
            RGB = photo1.getpixel((x, y))
            print("Even", y) # how far am I?
        else:
            RGB = photo2.getpixel((x, y))
            print("Odd", y) # how far aim I?
        R, G, B = RGB  # now you can use the RGB value
        data += struct.pack("B", R) + struct.pack("B", G) + struct.pack("B",B)
                 # store RGB values in byte format in variable "data"

new = Image.frombytes("RGB", (1920, 1080), data)# change value if not 1920 x 1080
new.save(output, "PNG") # make new image

I'm sorry if copying / pasting conflicts with Python indents.
It takes a good 10 minutes for this script to run on my laptop

  • Intel Core i5
  • 8 GB RAM
  • Run Linux (Fedora 30)
    Will this only take 10 minutes to capture all the individual pixel values, or is there anything that makes this code inefficient?

In addition, I currently use Python3.7 and 3, but can also use 2.7 if necessary.

I will write high quality articles and blog posts for $ 5

I will write high quality articles and blog posts

Hi,

Welcome to my GIG

If you need a professional creative author for your project. You are in the right place.

I am a versatile and professional creative writer, writing or writing in a variety of niches.

SO WHY SHOULD YOU CHOOSE ME FOR ALL CREATIVE WRITING NEEDS?

  • Original content and 100% plagiarism free
  • Perfect english and suitable formulation
  • Reasonable and discounted prices
  • 100% money back guarantee if you are not satisfied with my service!

If you have special wishes. Just send me a message.

I look forward to working for you.

Aaqib

,

Filenamesetter – How to get Mathematica to write to volume names containing a parameter value

I apologize for any duplication, as I can not find any trace of questions that I think I have asked. Maybe others have already asked and mine was struck off?

I have a program that runs all integers other than 2.5 for different values ​​of aspect ratio A and copies the results of the multiple representation to my hard disk. So, if I change and run again, I have to manually change all filenames to avoid overwriting the existing results for the previous one. This is time consuming and error prone. What is the syntax for a file name that has a numeric extension of the current value of A?

Get 3000+ medium claps on your media item for $ 3

Get 3000+ Medium Claps on your medium

Hi,

Medium is a very popular platform for reading content. Their user interface is user friendly and they are one of the
The most visited websites in the world.

All claps come from:

Worldwide human real users, no bots, no proxies. I promote posts on social media
Media to make your contribution viral. I know exactly how to become viral there
with all-in-one White Hat tactics that make your contribution to the virus
Press as much traffic as possible.

Get 3000+ Medium Claps on your medium

Properties :

– I will deliver it in a few hours
– Clapping is PERMANENT
– NO ADMIN. ACCESS OR PASSWORD REQUIRED!
– 100% MONEY BACK GUARANTEE ONLY ON SEOCLERKS

More options can be found in the extras

DO NOT HESITATE, ORDER NOW AND SEE MY MAGIC SHOW

Thank you for your time.

To write a wrapper for Netcat

I'm writing a small backdoor with Python 2.7 to wet my feet in offensive security tool writing with Python
This back door works that way. One variable is defined as a username and another as a password. These two are configurable. (They are saved in plain text.) See the second part of my question.) To my knowledge, Netcat does not allow me to provide a username / password for Netcat listeners, so I did some research and found a suggestion to write a wrapper. that serves as a login that runs before the Netcat shell connects, and compares the credentials with those in the backdoor if they match Netcat opening the backdoor My question is, how do I write this wrapper? I have very little knowledge about wrappers. What I want to know is what a wrapper is, how it's used and how I would write one generally and how I would write one for Netcat. To be clear that I do not want to receive the code, I just need a basic overview of how I would write one.
Now for the other problem, how the variables are used. They are defined inside the backdoor and are written to a file within / tmp. I have very limited knowledge of cryptography (I am still learning). So what would I do to protect this file? and I also want to learn how to obfuscate the variables so that someone with access to the program source code can not read the plain text version of the login. Any help / reading material would be helpful and grateful.
Edit: If someone has open source projects that do the same thing as what I'm writing, please link them in your answer so I can use their code as the start line for mine.
Edit: If you have any ideas / suggestions about what I can do better, add them to your answer as well

Linux – problem with read () to write the contents of the file to the screen and to another file in C.

I'm trying to copy the contents of a file to another file.
I also want to display the contents of the files on the screen, using system calls (if possible) when possible.

This is my code

#include
#include
#include
#include
#include
#include
#include
#include

#define PERMS 0644

char *workfile = "file1.txt";
char *workfile2 = "file2.txt";
int main(int argc, char *argv()){
        int fd;
        int fd2;
        int fd3;
        ssize_t nread0;
        ssize_t nread;
        char buf(1024);
        char buf2(1024);
        ssize_t nread2;

        const char msg() = "File 3 contains:";
        if( (fd= open(workfile, O_RDWR,PERMS)) == -1)
{
                printf("Couldn't open %sn", workfile);
                exit(1);
        }




        if( (fd2 = open(workfile2,O_RDWR,PERMS)) == -1)
        {
                printf("Couldn't open %sn",workfile2);
                exit(1);
        }



        while( nread =read(fd,buf,1024))
        {       if(lseek(fd2,0,SEEK_END) < 0) return 1;
                if(write(fd,buf,nread) && write(1,buf,nread)< nread )
                {
                        close(fd);
                        close(fd2);
                        return(-3);
                }
        }

close(fd);
if( nread ==-1){
        return (-4);
}
return 0;
}

When I try to write on the screen as well, the contents of file1 are not copied to file 2, but the contents of file 1 are written to the screen.

I also tried to add reading and writing outside the while loop with its separate buffer and ssize_t.

What causes this problem?